Mercurial > p > roundup > code
view test/test_memorydb.py @ 5077:88fc7202f87d
Remove 'import *' statement from test/memorydb.py
It is generally best to avoid 'import *' statements, particularly in
this case where objects in the global namespace are being propagated
through to an execfile(). The construction of the 'vars' variable is a
bit of a hack, but preferable to the alternative. Sometime in the future
it may be a good idea to do away with using execfile() to parse the
schema files.
| author | John Kristensen <john@jerrykan.com> |
|---|---|
| date | Fri, 10 Jun 2016 18:24:47 +1000 |
| parents | 364c54991861 |
| children | 62de601bdf6f |
line wrap: on
line source
import unittest, os, shutil, time from roundup import hyperdb from db_test_base import DBTest, ROTest, SchemaTest, config, setupSchema import memorydb class memorydbOpener: module = memorydb def nuke_database(self): # really kill it self.db = None db = None def open_database(self): if self.db is None: self.db = self.module.Database(config, 'admin') return self.db def setUp(self): self.open_database() setupSchema(self.db, 1, self.module) def tearDown(self): if self.db is not None: self.db.close() # nuke and re-create db for restore def nukeAndCreate(self): self.db.close() self.nuke_database() self.db = self.module.Database(config, 'admin') setupSchema(self.db, 0, self.module) class memorydbDBTest(memorydbOpener, DBTest, unittest.TestCase): pass class memorydbROTest(memorydbOpener, ROTest, unittest.TestCase): def setUp(self): self.db = self.module.Database(config) setupSchema(self.db, 0, self.module) class memorydbSchemaTest(memorydbOpener, SchemaTest, unittest.TestCase): pass from session_common import DBMTest class memorydbSessionTest(memorydbOpener, DBMTest, unittest.TestCase): def setUp(self): self.db = self.module.Database(config, 'admin') setupSchema(self.db, 1, self.module) self.sessions = self.db.sessions # vim: set filetype=python ts=4 sw=4 et si
