[Zodb-checkins] CVS: ZODB3/ZODB/tests - testStorageConfig.py:1.8
Barry Warsaw
barry@wooz.org
Fri, 3 Jan 2003 17:59:19 -0500
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv32014
Modified Files:
testStorageConfig.py
Log Message:
Here's a principled way to determine whether the BDBStorages are
available or not, and also fixes to all the tests so they won't crap
out or complain if not.
To test whether these storages are avialable (including all package
dependencies), do:
import BDBStorage
if BDBStorage.is_available:
# okay to use
Also, in BDBStorage/__init__.py do some cross-platform compatibility
for the bsddb module; in Python 2.3 we can just use the built-in
module, but in earlier Pythons we have to use bsddb3. Now you can
just use "from BDBStorage import db" to get the proper db object.
=== ZODB3/ZODB/tests/testStorageConfig.py 1.7 => 1.8 ===
--- ZODB3/ZODB/tests/testStorageConfig.py:1.7 Fri Jan 3 16:19:07 2003
+++ ZODB3/ZODB/tests/testStorageConfig.py Fri Jan 3 17:59:15 2003
@@ -21,8 +21,7 @@
from ZODB import StorageConfig
-class StorageTestCase(unittest.TestCase):
-
+class StorageTestBase(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUp(self)
self.tmpfn = tempfile.mktemp()
@@ -51,6 +50,8 @@
io = StringIO(text)
return context.loadFile(io)
+
+class StorageTestCase(StorageTestBase):
def testFileStorage(self):
from ZODB.FileStorage import FileStorage
sample = """
@@ -116,6 +117,8 @@
self.storage = StorageConfig.createStorage(storageconf)
self.assert_(isinstance(self.storage, DemoStorage))
+
+class BDBStorageTests(StorageTestBase):
def testFullStorage(self):
try:
from BDBStorage.BDBFullStorage import BDBFullStorage
@@ -168,8 +171,15 @@
# XXX _config isn't public
self.assert_(self.storage._config.cachesize, 1000)
+
def test_suite():
- return unittest.makeSuite(StorageTestCase)
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(StorageTestCase))
+ import BDBStorage
+ if BDBStorage.is_available:
+ suite.addTest(unittest.makeSuite(BDBStorageTests))
+ return suite
+
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')