[Zodb-checkins] CVS: ZODB3/ZODB/tests - testConfig.py:1.14

Fred L. Drake, Jr. fred at zope.com
Thu Jan 8 17:32:08 EST 2004


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

Modified Files:
	testConfig.py 
Log Message:
be more careful about not running tests for components that aren't
available


=== ZODB3/ZODB/tests/testConfig.py 1.13 => 1.14 ===
--- ZODB3/ZODB/tests/testConfig.py:1.13	Wed Dec 24 11:01:58 2003
+++ ZODB3/ZODB/tests/testConfig.py	Thu Jan  8 17:32:07 2004
@@ -21,7 +21,7 @@
 import ZODB.config
 import ZODB.tests
 from ZODB.POSException import ReadOnlyError
-from ZEO.ClientStorage import ClientDisconnected
+
 
 class ConfigTestBase(unittest.TestCase):
     def _opendb(self, s):
@@ -84,12 +84,27 @@
         """ % path
         self.assertRaises(ReadOnlyError, self._test, cfg)
 
+    def test_demo_config(self):
+        cfg = """
+        <zodb unused-name>
+          <demostorage>
+            name foo
+            <mappingstorage/>
+          </demostorage>
+        </zodb>
+        """
+        self._test(cfg)
+
+
+class ZEOConfigTest(ConfigTestBase):
     def test_zeo_config(self):
-        # We're looking for a port that doesn't exist so a connection attempt
-        # will fail.  Instead of elaborate logic to loop over a port
-        # calculation, we'll just pick a simple "random", likely to not-exist
-        # port number and add an elaborate comment explaining this instead.
-        # Go ahead, grep for 9.
+        # We're looking for a port that doesn't exist so a
+        # connection attempt will fail.  Instead of elaborate
+        # logic to loop over a port calculation, we'll just pick a
+        # simple "random", likely to not-exist port number and add
+        # an elaborate comment explaining this instead.  Go ahead,
+        # grep for 9.
+        from ZEO.ClientStorage import ClientDisconnected
         cfg = """
         <zodb>
           <zeoclient>
@@ -100,16 +115,6 @@
         """
         self.assertRaises(ClientDisconnected, self._test, cfg)
 
-    def test_demo_config(self):
-        cfg = """
-        <zodb unused-name>
-          <demostorage>
-            name foo
-            <mappingstorage/>
-          </demostorage>
-        </zodb>
-        """
-        self._test(cfg)
 
 class BDBConfigTest(ConfigTestBase):
     def setUp(self):
@@ -144,10 +149,21 @@
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(ZODBConfigTest))
-    # Only run the Berkeley tests if they are available
-    import BDBStorage
-    if BDBStorage.is_available:
-        suite.addTest(unittest.makeSuite(BDBConfigTest))
+    # Only run the ZEO test if ZEO is available
+    try:
+        import ZEO
+    except ImportError:
+        pass
+    else:
+        suite.addTest(unittest.makeSuite(ZEOConfigTest))
+    # Only run the Berkeley tests if bsddb is available
+    try:
+        import BDBStorage
+    except ImportError:
+        pass
+    else:
+        if BDBStorage.is_available:
+            suite.addTest(unittest.makeSuite(BDBConfigTest))
     return suite
 
 




More information about the Zodb-checkins mailing list