Last active
December 14, 2015 23:28
-
-
Save k4ml/5165424 to your computer and use it in GitHub Desktop.
Example of test generator
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
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