-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add built-in provider: RegexProvider at 2024-07-05T17:23:57+0800
- Loading branch information
1 parent
d36ab70
commit d271548
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import rstr | ||
from pistol_magazine import DataMocker | ||
|
||
|
||
class RegexProvider(DataMocker): | ||
def __init__(self, pattern): | ||
""" | ||
This class generates values that match a given regular expression pattern. | ||
Args: | ||
pattern: The regular expression pattern to generate matching values for. | ||
""" | ||
super().__init__() | ||
self.pattern = pattern | ||
|
||
def get_value(self): | ||
""" | ||
Returns a value generated to match the regular expression pattern. | ||
Returns: | ||
A string value that matches the regular expression pattern. | ||
""" | ||
return rstr.xeger(self.pattern) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
Faker==25.1.0 | ||
setuptools~=59.0.1 | ||
dicttoxml~=1.7.16 | ||
PyMySQL~=1.0.2 | ||
PyMySQL~=1.0.2 | ||
pytest~=6.2.4 | ||
rstr~=3.2.2 |