[Zodb-checkins] CVS: ZODB3/bsddb3Storage/bsddb3Storage/tests - ZODBTestBase.py:1.4

Barry Warsaw barry@wooz.org
Thu, 29 Aug 2002 15:52:48 -0400


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

Modified Files:
	ZODBTestBase.py 
Log Message:
Two changes to ensure that we remove the test-db file when an error
occurs.  First, inherit from BerkeleyTestBase which has proper setUp
and tearDown methods, and second, wrap the .abort() and ._close() call
in tearDown() in a try/finally so we're guaranteed that the base
class's tearDown gets run.


=== ZODB3/bsddb3Storage/bsddb3Storage/tests/ZODBTestBase.py 1.3 => 1.4 ===
--- ZODB3/bsddb3Storage/bsddb3Storage/tests/ZODBTestBase.py:1.3	Mon Feb 11 18:40:43 2002
+++ ZODB3/bsddb3Storage/bsddb3Storage/tests/ZODBTestBase.py	Thu Aug 29 15:52:47 2002
@@ -16,18 +16,17 @@
 
 import os
 import errno
-import unittest
 
 from ZODB import DB
+from bsddb3Storage.tests.BerkeleyTestBase import BerkeleyTestBase
 
 DBHOME = 'test-db'
 
 
 
-class ZODBTestBase(unittest.TestCase):
+class ZODBTestBase(BerkeleyTestBase):
     def setUp(self):
-        os.mkdir(DBHOME)
-
+        BerkeleyTestBase.setUp(self)
         try:
             self._storage = self.ConcreteStorage(DBHOME)
             self._db = DB(self._storage)
@@ -45,8 +44,8 @@
         # 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.
-        get_transaction().abort()
-        self._close()
-        for file in os.listdir(DBHOME):
-            os.unlink(os.path.join(DBHOME, file))
-        os.removedirs(DBHOME)
+        try:
+            get_transaction().abort()
+            self._close()
+        finally:
+            BerkeleyTestBase.tearDown(self)