Commit 18f51531 authored by Barry Warsaw's avatar Barry Warsaw

Fleshed out as the base class for testing storages at the ZODB level.

parent ab2bd85c
# Unit tests at the ZODB layer
# Base class for unit tests at the ZODB layer
import os
import errno
import unittest
from ZODB import DB
DBHOME = 'test-db'
class ZODBTestBase(unittest.TestCase):
def setUp(self):
os.mkdir(DBHOME)
try:
self._storage = self.ConcreteStorage(DBHOME)
self._db = DB(self._storage)
self._conn = self._db.open()
self._root = self._conn.root()
except:
self.tearDown()
raise
def _close(self):
self._db.close()
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.
get_transaction().abort()
self._close()
for file in os.listdir(DBHOME):
os.unlink(os.path.join(DBHOME, file))
os.removedirs(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