El mié, 06-07-2005 a las 14:19 -0400, Tim Peters escribió: > [Antonio Beamud Montero] > > In my app, I'm using ZODB to store data, the problem is that I > > have implemented several unittest, for every unit test I create the ZODB > > database and when the test finished I destroy the database (including > > files). When I run 2 test, the first is executed ok, but the second test > > give me the next Exception: > >
With the files attached I can simulate the same problem, i.e. when close the DB connection and after call commit()... But I can't see this pattern (i.e. open-close-commit) in my code... only when two tests are executed (i.e. create and destroy the database), and only occurs between two tests, the rest of the tests works well... This is very strange... I'll investigate and send you my conclusions Greetings
#!/usr/bin/env python import unittest from coll import Collector CollectorTestSuite = unittest.TestSuite() class CollectorTest(unittest.TestCase): def setUp(self): self.collect = None def tearDown(self): if self.collect: self.collect.drop() class Test1(CollectorTest): def runTest(self): self.collect = Collector() CollectorTestSuite.addTest(Test1("runTest")) allsuites = (CollectorTestSuite,) if __name__ == '__main__': csuite = unittest.TestSuite(allsuites) runner = unittest.TextTestRunner() runner.run(csuite)
from ZODB import DB, POSException, FileStorage from Persistence import Persistent from BTrees.OOBTree import OOBTree class Values(Persistent): def __init__(self): self._dicc = OOBTree() def set(self, v, s): self._dicc[v] = s class Collector: def __init__(self): self.storage = FileStorage.FileStorage('/tmp/zodb.fs', create=1) self.db = DB(self.storage) con = self.db.open() root = con.root() if not root.has_key('pendings'): root['pendings'] = Values() #root.close() con.close() #self.db.close() get_transaction().commit() def drop(self): self.db.close() self.storage.close() if __name__ == '__main__': c = Collector()
_______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev