Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of test generator
from some.business.logic.validation import validate_recipient
class TestSender(object):
def test_valid_recipients(self):
valid_recipients = (
'681919191',
'781881199',
'718188181',
)
def check_valid(recipient):
assert validate_recipient(recipient) == True
for recipient in valid_recipients:
check_valid.__name__ = 'test_valid_recipients_%s' % recipient
yield check_valid, recipient
# When executed, report will look like:-
test_valid_recipients_681919191 .... OK
test_valid_recipients_781881199 .... OK
test_valid_recipients_718188181 .... OK
Run 3 tests OK, 0 Fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment