Skip to content

Instantly share code, notes, and snippets.

@xordoquy
Created February 19, 2014 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xordoquy/9092484 to your computer and use it in GitHub Desktop.
Save xordoquy/9092484 to your computer and use it in GitHub Desktop.
import unittest
class MetaTest(type):
def __new__(cls, name, bases, attrs):
for k, v in attrs['generation_data'].items():
def test_function(self):
self.assertTrue(v[0]**2, v[1])
attrs['test_%s' % k] = test_function
return super(MetaTest, cls).__new__(cls, name, bases, attrs)
class TestDummy(unittest.TestCase):
__metaclass__ = MetaTest
generation_data = {
'data1': [1, 1],
'data2': [2, 4],
'data3': [3, 9],
}
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment