[Zope-Checkins] CVS: ZODB3/ZODB/tests - testConfig.py:1.3

Barry Warsaw barry@wooz.org
Fri, 3 Jan 2003 17:52:14 -0500


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv30251/ZODB/tests

Modified Files:
	testConfig.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/testConfig.py 1.2 => 1.3 ===
--- ZODB3/ZODB/tests/testConfig.py:1.2	Fri Jan  3 16:19:07 2003
+++ ZODB3/ZODB/tests/testConfig.py	Fri Jan  3 17:52:11 2003
@@ -108,11 +108,9 @@
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(ZODBConfigTest))
-    try:
-        import BDBStorage.BDBFullStorage
-    except ImportError:
-        pass
-    else:
+    # Only run the Berkeley tests if they are available
+    import BDBStorage
+    if BDBStorage.is_available:
         suite.addTest(unittest.makeSuite(BDBConfigTest))
     return suite