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

Barry Warsaw barry@wooz.org
Tue, 3 Sep 2002 13:21:52 -0400


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

Modified Files:
	BerkeleyTestBase.py 
Log Message:
Refactor shutdown into _zap_dbhome()


=== ZODB3/bsddb3Storage/bsddb3Storage/tests/BerkeleyTestBase.py 1.6 => 1.7 ===
--- ZODB3/bsddb3Storage/bsddb3Storage/tests/BerkeleyTestBase.py:1.6	Thu Aug 29 15:51:15 2002
+++ ZODB3/bsddb3Storage/bsddb3Storage/tests/BerkeleyTestBase.py	Tue Sep  3 13:21:52 2002
@@ -15,6 +15,7 @@
 # Basic test framework class for both the Full and Minimal Berkeley storages
 
 import os
+import errno
 from ZODB.tests.StorageTestBase import StorageTestBase
 
 DBHOME = 'test-db'
@@ -22,24 +23,31 @@
 
 
 class BerkeleyTestBase(StorageTestBase):
+    def _zap_dbhome(self):
+        # 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)
+        except OSError, e:
+            if e.errno <> errno.ENOENT: raise
+
     def setUp(self):
         StorageTestBase.setUp(self)
+        self._zap_dbhome()
         os.mkdir(DBHOME)
         try:
             self._storage = self.ConcreteStorage(DBHOME)
         except:
-            self.tearDown()
+            self._zap_dbhome()
             raise
 
     def tearDown(self):
-        # 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.
-        for file in os.listdir(DBHOME):
-            os.unlink(os.path.join(DBHOME, file))
-        os.removedirs(DBHOME)
         StorageTestBase.tearDown(self)
+        self._zap_dbhome()