Last active
December 24, 2015 20:49
-
-
Save kissgyorgy/6860417 to your computer and use it in GitHub Desktop.
Python: nosetests test generator
This file contains hidden or 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
# I don't know why a simple self.check_attribute doesn't work. | |
# Nosetests doc says something about this, but not the reason | |
# https://nose.readthedocs.org/en/latest/writing_tests.html#test-generators | |
class BaseTest(object): | |
@staticmethod | |
def check_attribute(self, attr, res): | |
assert getattr(self.hand, attr) == res | |
def test_header(self): | |
for attribute, result in self.header_results.items(): | |
self.hand = Parser(self.data) | |
yield self.check_attribute, self, attribute, result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment