[Zodb-checkins] CVS: ZODB3/bsddb3Storage/bsddb3Storage/tests - BerkeleyTestBase.py:1.7.2.1

Barry Warsaw barry@wooz.org
Thu, 24 Oct 2002 09:55:49 -0400


Update of /cvs-repository/ZODB3/bsddb3Storage/bsddb3Storage/tests
In directory cvs.zope.org:/tmp/cvs-serv17810

Modified Files:
      Tag: bdb-nolocks
	BerkeleyTestBase.py 
Log Message:
Refactor setUp() and tearDown() code so that it'll work better with
RecoveryStorage tests (which need to create two storages).


=== ZODB3/bsddb3Storage/bsddb3Storage/tests/BerkeleyTestBase.py 1.7 => 1.7.2.1 ===
--- ZODB3/bsddb3Storage/bsddb3Storage/tests/BerkeleyTestBase.py:1.7	Tue Sep  3 13:21:52 2002
+++ ZODB3/bsddb3Storage/bsddb3Storage/tests/BerkeleyTestBase.py	Thu Oct 24 09:55:48 2002
@@ -23,31 +23,35 @@
 
 
 class BerkeleyTestBase(StorageTestBase):
-    def _zap_dbhome(self):
+    def _zap_dbhome(self, dir):
         # If the tests exited with any uncommitted objects, they'll blow up
         # subsequent tests because the next transaction commit will try to
         # commit those object.  But they're tied to closed databases, so
         # that's broken.  Aborting the transaction now saves us the headache.
         try:
-            for file in os.listdir(DBHOME):
-                os.unlink(os.path.join(DBHOME, file))
-            os.removedirs(DBHOME)
+            for file in os.listdir(dir):
+                os.unlink(os.path.join(dir, file))
+            os.removedirs(dir)
         except OSError, e:
-            if e.errno <> errno.ENOENT: raise
+            if e.errno <> errno.ENOENT:
+                raise
 
-    def setUp(self):
-        StorageTestBase.setUp(self)
-        self._zap_dbhome()
-        os.mkdir(DBHOME)
+    def _mk_dbhome(self, dir):
+        os.mkdir(dir)
         try:
-            self._storage = self.ConcreteStorage(DBHOME)
+            return self.ConcreteStorage(dir)
         except:
-            self._zap_dbhome()
+            self._zap_dbhome(dir)
             raise
 
+    def setUp(self):
+        StorageTestBase.setUp(self)
+        self._zap_dbhome(DBHOME)
+        self._storage = self._mk_dbhome(DBHOME)
+
     def tearDown(self):
         StorageTestBase.tearDown(self)
-        self._zap_dbhome()
+        self._zap_dbhome(DBHOME)