Skip to content

Instantly share code, notes, and snippets.

@k4ml
Last active December 14, 2015 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k4ml/5165424 to your computer and use it in GitHub Desktop.
Save k4ml/5165424 to your computer and use it in GitHub Desktop.
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