Commit 34d0725e authored by Julien Muchembled's avatar Julien Muchembled

qa: at the end of each ZODB test, check there is no storage space leak

parent 28e097c8
...@@ -41,23 +41,53 @@ class ZODBTestCase(TestCase): ...@@ -41,23 +41,53 @@ class ZODBTestCase(TestCase):
if functional: if functional:
kw['temp_dir'] = self.getTempDirectory() kw['temp_dir'] = self.getTempDirectory()
self.neo = NEOCluster(**kw) self.neo = NEOCluster(**kw)
self.neo.start()
self.open()
def _tearDown(self, success): def __init__(self, methodName):
try: super(ZODBTestCase, self).__init__(methodName)
test = getattr(self, methodName).__func__
def runTest():
try:
self.neo.start()
self.open()
test(self)
if not functional:
orphan = self.neo.storage.dm.getOrphanList()
finally:
self.close()
if functional:
self.neo.stop()
else:
self.neo.stop(None)
if functional: if functional:
self.neo.stop() dm = self.neo.getSQLConnection(*self.neo.db_list)
else: try:
self.neo.stop(None) dm.setup()
except Exception: orphan = set(dm.getOrphanList())
if success: orphan.difference_update(dm._uncommitted_data)
raise finally:
del self.neo, self._storage dm.close()
self.assertFalse(orphan)
setattr(self, methodName, runTest)
def _tearDown(self, success):
del self.neo
super(ZODBTestCase, self)._tearDown(success) super(ZODBTestCase, self)._tearDown(success)
assertEquals = failUnlessEqual = TestCase.assertEqual assertEquals = failUnlessEqual = TestCase.assertEqual
assertNotEquals = failIfEqual = TestCase.assertNotEqual assertNotEquals = failIfEqual = TestCase.assertNotEqual
def open(self, **kw): def open(self, **kw):
self._storage = self.neo.getZODBStorage(**kw) self._open(_storage=self.neo.getZODBStorage(**kw))
def _open(self, **kw):
self.close()
(attr, value), = kw.iteritems()
setattr(self, attr, value)
def close():
getattr(self, attr).close()
delattr(self, attr)
del self.close
self.close = close
def close(self):
pass
...@@ -22,13 +22,8 @@ from . import ZODBTestCase ...@@ -22,13 +22,8 @@ from . import ZODBTestCase
class NEOZODBTests(ZODBTestCase, testZODB.ZODBTests): class NEOZODBTests(ZODBTestCase, testZODB.ZODBTests):
def setUp(self): def open(self):
super(NEOZODBTests, self).setUp() self._open(_db=ZODB.DB(self.neo.getZODBStorage()))
self._db = ZODB.DB(self._storage)
def _tearDown(self, success):
self._db.close()
super(NEOZODBTests, self)._tearDown(success)
if __name__ == "__main__": if __name__ == "__main__":
suite = unittest.makeSuite(NEOZODBTests, 'check') suite = unittest.makeSuite(NEOZODBTests, 'check')
......
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