Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Last active December 24, 2015 20:49
Show Gist options
  • Save kissgyorgy/6860417 to your computer and use it in GitHub Desktop.
Save kissgyorgy/6860417 to your computer and use it in GitHub Desktop.
Python: nosetests test generator
# 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