[Zodb-checkins] CVS: Packages/bsddb3Storage - test_create.py:1.3

barry@digicool.com barry@digicool.com
Fri, 30 Mar 2001 14:45:02 -0500 (EST)


Update of /cvs-repository/Packages/bsddb3Storage/test
In directory korak:/tmp/cvs-serv32109

Modified Files:
	test_create.py 
Log Message:
BaseFramework => MinimalBaseFramework

MinimalBaseFramework.setUp(): Wrap the creation and opening of the
database in a try/except so that we guarantee that tearDown() is
called if there are any errors in database creation.

tearDown(): Added this to make sure that the test directories are
removed when the test is done.

FullBaseFramework: New class to mirror the same tests for the Full
database.  Based on MinimalBaseFramework.  This could use some
factorization.

DBHomeTest => MinimalDBHomeTest

FullDBHomeTest: New class to mirror the same tests for the Full
database.  Based on MinimalDBHomeTest.  This could use some
factorization.

Added __main__ section so this test can be run standalone.



--- Updated File test_create.py in package Packages/bsddb3Storage --
--- test_create.py	2001/03/16 23:56:58	1.2
+++ test_create.py	2001/03/30 19:45:01	1.3
@@ -6,7 +6,7 @@
 
 
 
-class BaseFramework(unittest.TestCase):
+class MinimalBaseFramework(unittest.TestCase):
     def setUp(self):
         import Minimal
         from ZODB import DB
@@ -14,10 +14,14 @@
         self._dbhome = 'test-db'
         os.mkdir(self._dbhome)
 
-        self._storage = Minimal.Minimal(self._dbhome)
-        self._db = DB(self._storage)
-        self._conn = self._db.open()
-        self._root = self._conn.root()
+        try:
+            self._storage = Minimal.Minimal(self._dbhome)
+            self._db = DB(self._storage)
+            self._conn = self._db.open()
+            self._root = self._conn.root()
+        except:
+            self.tearDown()
+            raise
 
     def tearDown(self):
         for file in os.listdir(self._dbhome):
@@ -26,14 +30,51 @@
 
 
 
-class DBHomeTest(BaseFramework):
+class FullBaseFramework(unittest.TestCase):
+    def setUp(self):
+        import Full
+        from ZODB import DB
+
+        self._dbhome = 'test-db'
+        os.mkdir(self._dbhome)
+
+        try:
+            self._storage = Full.Full(self._dbhome)
+            self._db = DB(self._storage)
+            self._conn = self._db.open()
+            self._root = self._conn.root()
+        except:
+            self.tearDown()
+            raise
+
+    def tearDown(self):
+        for file in os.listdir(self._dbhome):
+            os.unlink(os.path.join(self._dbhome, file))
+        os.removedirs(self._dbhome)
+
+
+
+class MinimalDBHomeTest(MinimalBaseFramework):
     def checkDBHomeExists(self):
-        """Database creation with an explicit db_home create the directory"""
+        """Minimal: Database creation w/ explicit db_home"""
         assert os.path.isdir(self._dbhome)
 
 
 
+class FullDBHomeTest(FullBaseFramework):
+    def checkDBHomeExists(self):
+        """Full: Database creation w/ explicit db_home"""
+        assert os.path.isdir(self._dbhome)
+
+
+
 def suite():
     suite = unittest.TestSuite()
-    suite.addTest(DBHomeTest('checkDBHomeExists'))
+    suite.addTest(MinimalDBHomeTest('checkDBHomeExists'))
+    suite.addTest(FullDBHomeTest('checkDBHomeExists'))
     return suite
+
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='suite')