diff test/test_xmlrpc.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 3b9252085ba9
children 380d8d8b30a3
line wrap: on
line diff
--- a/test/test_xmlrpc.py	Tue Jan 12 04:33:53 2016 +0300
+++ b/test/test_xmlrpc.py	Thu Aug 20 14:44:49 2015 +1000
@@ -16,7 +16,8 @@
 
 import db_test_base
 
-class TestCase(unittest.TestCase):
+
+class XmlrpcTest(object):
 
     backend = None
 
@@ -245,12 +246,29 @@
         for n, r in enumerate(result):
             self.assertEqual(r, results[n])
 
+
+class anydbmXmlrpcTest(XmlrpcTest, unittest.TestCase):
+    backend = 'anydbm'
+
+
+class mysqlXmlrpcTest(XmlrpcTest, unittest.TestCase):
+    backend = 'mysql'
+
+
+class sqliteXmlrpcTest(XmlrpcTest, unittest.TestCase):
+    backend = 'sqlite'
+
+
+class postgresqlXmlrpcTest(XmlrpcTest, unittest.TestCase):
+    backend = 'postgresql'
+
+
 def test_suite():
     suite = unittest.TestSuite()
-    for l in list_backends():
-        dct = dict(backend = l)
-        subcls = type(TestCase)('TestCase_%s'%l, (TestCase,), dct)
-        suite.addTest(unittest.makeSuite(subcls))
+    suite.addTest(unittest.makeSuite(anydbmXmlrpcTest))
+    suite.addTest(unittest.makeSuite(mysqlXmlrpcTest))
+    suite.addTest(unittest.makeSuite(sqliteXmlrpcTest))
+    suite.addTest(unittest.makeSuite(postgresqlXmlrpcTest))
     return suite
 
 if __name__ == '__main__':

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