Mercurial > p > roundup > code
comparison test/db_test_base.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 | a116de39e38c |
| children | 380d8d8b30a3 |
comparison
equal
deleted
inserted
replaced
| 5032:fc0f7655411b | 5033:63c79c0992ae |
|---|---|
| 119 db.commit() | 119 db.commit() |
| 120 | 120 |
| 121 # nosy tests require this | 121 # nosy tests require this |
| 122 db.security.addPermissionToRole('User', 'View', 'msg') | 122 db.security.addPermissionToRole('User', 'View', 'msg') |
| 123 | 123 |
| 124 class MyTestCase(unittest.TestCase): | 124 |
| 125 class MyTestCase(object): | |
| 125 def tearDown(self): | 126 def tearDown(self): |
| 126 if hasattr(self, 'db'): | 127 if hasattr(self, 'db'): |
| 127 self.db.close() | 128 self.db.close() |
| 128 if os.path.exists(config.DATABASE): | 129 if os.path.exists(config.DATABASE): |
| 129 shutil.rmtree(config.DATABASE) | 130 shutil.rmtree(config.DATABASE) |
| 2461 nodeid = n.supervisor | 2462 nodeid = n.supervisor |
| 2462 self.db.clearCache() | 2463 self.db.clearCache() |
| 2463 ae (result, ['4', '5', '6', '7', '8', '1', '2', '3']) | 2464 ae (result, ['4', '5', '6', '7', '8', '1', '2', '3']) |
| 2464 | 2465 |
| 2465 | 2466 |
| 2466 class ClassicInitBase(unittest.TestCase): | 2467 class ClassicInitBase(object): |
| 2467 count = 0 | 2468 count = 0 |
| 2468 db = None | 2469 db = None |
| 2469 | 2470 |
| 2470 def setUp(self): | 2471 def setUp(self): |
| 2471 ClassicInitBase.count = ClassicInitBase.count + 1 | 2472 ClassicInitBase.count = ClassicInitBase.count + 1 |
