New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FuzzyString attribute #97

wants to merge 3 commits into
base: master
Jump to file or symbol
Failed to load files and symbols.
+14 −4
Diff settings


Just for now

Viewing a subset of changes. View all

Added chars to FuzzyString constructor.

Can now supply any characterset for choosing random characters. Added
  • Loading branch information...
Jon Dufresne
Jon Dufresne committed Oct 18, 2013
commit 3ae9fadc132aa488191dc85ccd035daf8aeaf370
@@ -62,16 +62,26 @@ def fuzz(self):
class FuzzyString(BaseFuzzyAttribute):
"""Random string with a given prefix."""
"""Random string with a given prefix.
def __init__(self, prefix='', length=12, **kwargs):
Generates random string of length from set chars. Random string is
appended to prefix if supplied. Length defaults to 12 and
character set defaults to lower and uppercase ascii letters.
Useful for generating unique attributes where the exact value is
not important.
def __init__(self, prefix='', length=12,
chars=string.ascii_letters, **kwargs):
self.prefix = prefix
self.length = length
self.chars = chars
super(FuzzyString, self).__init__(**kwargs)
def fuzz(self):
chars = [random.choice(string.ascii_letters)
for _ in range(self.length)]
chars = [random.choice(self.chars) for _ in range(self.length)]
return self.prefix + ''.join(chars)
ProTip! Use n and p to navigate between commits in a pull request.