[Zope3-checkins] CVS: ZODB4/src/zodb/storage/tests - test_config.py:1.4

Barry Warsaw barry@wooz.org
Wed, 22 Jan 2003 16:53:29 -0500


Update of /cvs-repository/ZODB4/src/zodb/storage/tests
In directory cvs.zope.org:/tmp/cvs-serv15817

Modified Files:
	test_config.py 
Log Message:
use the same mechanism as other tests to decide whether or not to run
the Berkeley related tests.


=== ZODB4/src/zodb/storage/tests/test_config.py 1.3 => 1.4 ===
--- ZODB4/src/zodb/storage/tests/test_config.py:1.3	Fri Jan  3 16:52:25 2003
+++ ZODB4/src/zodb/storage/tests/test_config.py	Wed Jan 22 16:53:26 2003
@@ -1,3 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
 import os
 import shutil
 import tempfile
@@ -8,8 +22,8 @@
 
 from zodb import config
 
-class StorageTestCase(unittest.TestCase):
 
+class StorageTestBase(unittest.TestCase):
     def setUp(self):
         unittest.TestCase.setUp(self)
         self.tmpfn = tempfile.mktemp()
@@ -38,6 +52,8 @@
         io = StringIO(text)
         return context.loadFile(io)
 
+
+class StorageTestCase(StorageTestBase):
     def testFileStorage(self):
         from zodb.storage.file import FileStorage
         sample = """
@@ -106,13 +122,9 @@
         self.storage = config.createStorage(storageconf)
         self.assert_(isinstance(self.storage, MappingStorage))
 
+
+class BerkeleyTestCase(StorageTestBase):
     def testFullStorage(self):
-        try:
-            from zodb.storage.bdbfull import BDBFullStorage
-        except ImportError:
-##            import warnings
-##            warnings.warn('No BDBStorage available', RuntimeWarning)
-            return
         sample = """
         <Storage>
         type       BDBFullStorage
@@ -135,12 +147,6 @@
         self.assert_(self.storage._config.cachesize, 1000)
 
     def testMinimalStorage(self):
-        try:
-            from zodb.storage.bdbminimal import BDBMinimalStorage
-        except ImportError:
-##            import warnings
-##            warnings.warn('No BDBStorage available', RuntimeWarning)
-            return
         sample = """
         <Storage>
         type       BDBMinimalStorage
@@ -162,8 +168,21 @@
         # XXX _config isn't public
         self.assert_(self.storage._config.cachesize, 1000)
 
+
+test_classes = [StorageTestCase]
+
+from zodb.storage.base import berkeley_is_available
+if berkeley_is_available:
+    test_classes.append(BerkeleyTestCase)
+
+
 def test_suite():
-    return unittest.makeSuite(StorageTestCase)
+    suite = unittest.TestSuite()
+    for klass in test_classes:
+        sub = unittest.makeSuite(klass)
+        suite.addTest(sub)
+    return suite
+
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')