Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 5032:fc0f7655411b | 5033:63c79c0992ae |
|---|---|
| 14 from roundup.hyperdb import String | 14 from roundup.hyperdb import String |
| 15 from roundup.cgi import TranslationService | 15 from roundup.cgi import TranslationService |
| 16 | 16 |
| 17 import db_test_base | 17 import db_test_base |
| 18 | 18 |
| 19 class TestCase(unittest.TestCase): | 19 |
| 20 class XmlrpcTest(object): | |
| 20 | 21 |
| 21 backend = None | 22 backend = None |
| 22 | 23 |
| 23 def setUp(self): | 24 def setUp(self): |
| 24 self.dirname = '_test_xmlrpc' | 25 self.dirname = '_test_xmlrpc' |
| 243 'keyword': [], 'title': 'i2', 'nosy': [], 'messages': [], | 244 'keyword': [], 'title': 'i2', 'nosy': [], 'messages': [], |
| 244 'priority': None, 'assignedto': None, 'superseder': []}] | 245 'priority': None, 'assignedto': None, 'superseder': []}] |
| 245 for n, r in enumerate(result): | 246 for n, r in enumerate(result): |
| 246 self.assertEqual(r, results[n]) | 247 self.assertEqual(r, results[n]) |
| 247 | 248 |
| 249 | |
| 250 class anydbmXmlrpcTest(XmlrpcTest, unittest.TestCase): | |
| 251 backend = 'anydbm' | |
| 252 | |
| 253 | |
| 254 class mysqlXmlrpcTest(XmlrpcTest, unittest.TestCase): | |
| 255 backend = 'mysql' | |
| 256 | |
| 257 | |
| 258 class sqliteXmlrpcTest(XmlrpcTest, unittest.TestCase): | |
| 259 backend = 'sqlite' | |
| 260 | |
| 261 | |
| 262 class postgresqlXmlrpcTest(XmlrpcTest, unittest.TestCase): | |
| 263 backend = 'postgresql' | |
| 264 | |
| 265 | |
| 248 def test_suite(): | 266 def test_suite(): |
| 249 suite = unittest.TestSuite() | 267 suite = unittest.TestSuite() |
| 250 for l in list_backends(): | 268 suite.addTest(unittest.makeSuite(anydbmXmlrpcTest)) |
| 251 dct = dict(backend = l) | 269 suite.addTest(unittest.makeSuite(mysqlXmlrpcTest)) |
| 252 subcls = type(TestCase)('TestCase_%s'%l, (TestCase,), dct) | 270 suite.addTest(unittest.makeSuite(sqliteXmlrpcTest)) |
| 253 suite.addTest(unittest.makeSuite(subcls)) | 271 suite.addTest(unittest.makeSuite(postgresqlXmlrpcTest)) |
| 254 return suite | 272 return suite |
| 255 | 273 |
| 256 if __name__ == '__main__': | 274 if __name__ == '__main__': |
| 257 runner = unittest.TextTestRunner() | 275 runner = unittest.TextTestRunner() |
| 258 unittest.main(testRunner=runner) | 276 unittest.main(testRunner=runner) |
