comparison test/test_jinja2.py @ 5033:63c79c0992ae

Update tests to work with py.test py.test searches for any class that looks like a TestCase in the test directory and tries to run them as tests. Some of the classes that inherit TestCase are not meant to be run and are only intended to be "helper classes". Only the tests of the classes that inherit the "helper classes" should be run. If we convert these "helper classes" to be "mixins" py.test should not pick them up.
author John Kristensen <john@jerrykan.com>
date Thu, 20 Aug 2015 14:44:49 +1000
parents 3766e0ca8e7a
children 364c54991861
comparison
equal deleted inserted replaced
5032:fc0f7655411b 5033:63c79c0992ae
18 18
19 class TestCase_Zero(unittest.TestCase): 19 class TestCase_Zero(unittest.TestCase):
20 def test_zero(self): 20 def test_zero(self):
21 self.assertEqual(True, True) 21 self.assertEqual(True, True)
22 22
23 class TestCase(unittest.TestCase): 23
24 class Jinja2Test(object):
24 """Sets up and tears down an instance with database contents. 25 """Sets up and tears down an instance with database contents.
25 26
26 Setup and teardown modelled after the use of db_test_base 27 Setup and teardown modelled after the use of db_test_base
27 by several modules like test_xmlrpc and test_userauditor. 28 by several modules like test_xmlrpc and test_userauditor.
28 29
46 def test_zero(self): 47 def test_zero(self):
47 """Do nothing just make sure that setup and teardown works.""" 48 """Do nothing just make sure that setup and teardown works."""
48 pass 49 pass
49 50
50 51
52 class anydbmJinja2Test(Jinja2Test, unittest.TestCase):
53 backend = 'anydbm'
54
51 55
52 def test_suite(): 56 def test_suite():
53 suite = unittest.TestSuite() 57 suite = unittest.TestSuite()
54 58
55 suite.addTest(unittest.makeSuite(TestCase_Zero)) 59 suite.addTest(unittest.makeSuite(TestCase_Zero))
56 60
57 # only using one database backend for now, not sure if doing all 61 # only using one database backend for now, not sure if doing all
58 # backends will keep the test focussed enough to be useful for the used 62 # backends will keep the test focussed enough to be useful for the used
59 # computing time. Would be okay to change in the future. 63 # computing time. Would be okay to change in the future.
60 # for l in list_backends(): 64 # for l in list_backends():
61 for l in ['anydbm']: 65 suite.addTest(unittest.makeSuite(anydbmJinja2Test))
62 dct = dict(backend = l)
63 subcls = type(TestCase)('TestCase_%s'%l, (TestCase,), dct)
64 suite.addTest(unittest.makeSuite(subcls))
65 66
66 return suite 67 return suite
67 68
68 # Other roundup test source files have an if __name__ == '__main__': here 69 # Other roundup test source files have an if __name__ == '__main__': here
69 # but I'm not sure if this is still helpful. So left out for now. 70 # but I'm not sure if this is still helpful. So left out for now.

Roundup Issue Tracker: http://roundup-tracker.org/