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
Introduce formatted string generator #76
Conversation
I wonder why does it hate line 807 in python 2.6. I think doing |
Using |
|
||
Example of the formatter is: | ||
|
||
``"test_vm_{alpha:12|.lower}"`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of the formatter is::
'test_vm_{alpha:12|.lower}'
See literal blocks.
Introduce `fauxfactory.generate()` which takes a string with formatting similar to `"".format()` but instead of inserting strings, it randomizes the values based on what is located inside the braces.
@Ichimonji10 the pylint comment as you said triggered an error in all of the python versions. I have put the |
Doesn't help either. |
I think this is a good addition and a good start. The next step would be allowing one or more generators to be specified. We need to take care of not reinventing some behaviours implemented by other libraries like rstr [1] |
Thinking better... I think that we can have the same behaviour without the need of any additional logic: generate("test_vm_{alpha:12|.lower}")
# is the same as
'test_vm_{0}'.format(gen_alpha(12).lower()) With that said, by adding this kind of generator will not bring any real improvement because we can mix the python string formatting with the generators without the overhead of parsing the generator string. Also the default string formatting allows generating not just one but many formats in the same string like: 'test_vm_{0}_{1}'.format(
gen_alpha(5).lower(),
gen_integer(3)
) |
The |
ok |
Introduce
fauxfactory.generate()
which takes a string with formatting similar to"".format()
but instead of inserting strings, it randomizes the values based on what is located inside the braces.