Commit 36c9e522 authored by Barry Warsaw's avatar Barry Warsaw

Refactor shutdown into _zap_dbhome()

parent fa9bcb0b
......@@ -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 @@ DBHOME = 'test-db'
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()
......
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