diff 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
line wrap: on
line diff
--- a/test/test_jinja2.py	Tue Jan 12 04:33:53 2016 +0300
+++ b/test/test_jinja2.py	Thu Aug 20 14:44:49 2015 +1000
@@ -20,7 +20,8 @@
     def test_zero(self):
         self.assertEqual(True, True)
 
-class TestCase(unittest.TestCase):
+
+class Jinja2Test(object):
     """Sets up and tears down an instance with database contents.
 
     Setup and teardown modelled after the use of db_test_base
@@ -48,6 +49,9 @@
         pass
 
 
+class anydbmJinja2Test(Jinja2Test, unittest.TestCase):
+    backend = 'anydbm'
+
 
 def test_suite():
     suite = unittest.TestSuite()
@@ -58,10 +62,7 @@
     # backends will keep the test focussed enough to be useful for the used
     # computing time. Would be okay to change in the future.
     # for l in list_backends():
-    for l in ['anydbm']:
-        dct = dict(backend = l)
-        subcls = type(TestCase)('TestCase_%s'%l, (TestCase,), dct)
-        suite.addTest(unittest.makeSuite(subcls))
+    suite.addTest(unittest.makeSuite(anydbmJinja2Test))
 
     return suite
 

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