Commit 469966dc authored by Barry Warsaw's avatar Barry Warsaw

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.
parent 779aa469
......@@ -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 @@ class ZODBTestBase(unittest.TestCase):
# 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment