[Zope3-checkins] CVS: ZODB4/src/zodb/zeo/tests - invalid.py:1.3

Jeremy Hylton jeremy@zope.com
Fri, 20 Jun 2003 10:14:25 -0400


Update of /cvs-repository/ZODB4/src/zodb/zeo/tests
In directory cvs.zope.org:/tmp/cvs-serv7472

Modified Files:
	invalid.py 
Log Message:
Close DB objects in tearDown() so that they are guaranteed to occur.


=== ZODB4/src/zodb/zeo/tests/invalid.py 1.2 => 1.3 ===
--- ZODB4/src/zodb/zeo/tests/invalid.py:1.2	Thu Jun 19 17:41:07 2003
+++ ZODB4/src/zodb/zeo/tests/invalid.py	Fri Jun 20 10:14:24 2003
@@ -175,6 +175,20 @@
     level = 2
     DELAY = 15  # number of seconds the main thread lets the workers run
 
+    def setUp(self):
+        super(InvalidationTests, self).setUp()
+        self.dbs = []
+
+    def tearDown(self):
+        for db in self.dbs:
+            db.close()
+        super(InvalidationTests, self).tearDown()
+
+    def db(self, storage):
+        db = DB(storage)
+        self.dbs.append(db)
+        return db
+
     def _check_tree(self, cn, tree):
         # Make sure the BTree is sane and that all the updates persisted.
         retries = 3
@@ -218,14 +232,14 @@
     def testConcurrentUpdates2Storages(self):
         self._storage = storage1 = self.openClientStorage()
         storage2 = self.openClientStorage(cache="2")
-        db1 = DB(storage1)
+        db1 = self.db(storage1)
         stop = threading.Event()
 
         cn = db1.open()
         tree = cn.root()["tree"] = OOBTree()
         get_transaction().commit()
 
-        db2 = DB(storage2)
+        db2 = self.db(storage2)
         # Run two threads that update the BTree
         t1 = StressThread(self, db1, stop, 1, 1)
         t2 = StressThread(self, db2, stop, 2, 2)
@@ -236,12 +250,10 @@
         self._check_threads(tree, t1, t2)
 
         cn.close()
-        db1.close()
-        db2.close()
 
     def testConcurrentUpdates1Storage(self):
         self._storage = storage1 = self.openClientStorage()
-        db1 = DB(storage1)
+        db1 = self.db(storage1)
         stop = threading.Event()
 
         cn = db1.open()
@@ -258,18 +270,17 @@
         self._check_threads(tree, t1, t2)
 
         cn.close()
-        db1.close()
 
     def testConcurrentUpdates2StoragesMT(self):
         self._storage = storage1 = self.openClientStorage()
-        db1 = DB(storage1)
+        db1 = self.db(storage1)
         stop = threading.Event()
 
         cn = db1.open()
         tree = cn.root()["tree"] = OOBTree()
         get_transaction().commit()
 
-        db2 = DB(self.openClientStorage(cache="2"))
+        db2 = self.db(self.openClientStorage(cache="2"))
         # Run three threads that update the BTree.
         # Two of the threads share a single storage so that it
         # is possible for both threads to read the same object
@@ -285,12 +296,10 @@
         self._check_threads(tree, t1, t2, t3)
 
         cn.close()
-        db1.close()
-        db2.close()
 
     def testConcurrentUpdatesInVersions(self):
         self._storage = storage1 = self.openClientStorage()
-        db1 = DB(storage1)
+        db1 = self.db(storage1)
         stop = threading.Event()
 
         cn = db1.open()
@@ -298,7 +307,7 @@
         get_transaction().commit()
         cn.close()
 
-        db2 = DB(self.openClientStorage(cache="2"))
+        db2 = self.db(self.openClientStorage(cache="2"))
         # Run three threads that update the BTree.
         # Two of the threads share a single storage so that it
         # is possible for both threads to read the same object
@@ -314,6 +323,4 @@
         self._check_threads(tree, t1, t2, t3)
 
         cn.close()
-        db1.close()
-        db2.close()