[Checkins] SVN: ZODB/trunk/src/ZEO/tests/ TestThread objects expect to have a _testcase attr, but didn't have

Jim Fulton jim at zope.com
Tue Feb 2 11:50:50 EST 2010


Log message for revision 108722:
  TestThread objects expect to have a _testcase attr, but didn't have
  one. Added a constructor argument to give them one.
  

Changed:
  U   ZODB/trunk/src/ZEO/tests/CommitLockTests.py
  U   ZODB/trunk/src/ZEO/tests/InvalidationTests.py
  U   ZODB/trunk/src/ZEO/tests/TestThread.py

-=-
Modified: ZODB/trunk/src/ZEO/tests/CommitLockTests.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/CommitLockTests.py	2010-02-02 16:50:48 UTC (rev 108721)
+++ ZODB/trunk/src/ZEO/tests/CommitLockTests.py	2010-02-02 16:50:49 UTC (rev 108722)
@@ -35,11 +35,11 @@
     # run the entire test in a thread so that the blocking call for
     # tpc_vote() doesn't hang the test suite.
 
-    def __init__(self, storage, trans):
+    def __init__(self, test, storage, trans):
         self.storage = storage
         self.trans = trans
         self.ready = threading.Event()
-        TestThread.__init__(self)
+        TestThread.__init__(self, test)
 
     def testrun(self):
         try:
@@ -111,7 +111,7 @@
             txn = transaction.Transaction()
             tid = self._get_timestamp()
 
-            t = WorkerThread(storage, txn)
+            t = WorkerThread(self, storage, txn)
             self._threads.append(t)
             t.start()
             t.ready.wait()

Modified: ZODB/trunk/src/ZEO/tests/InvalidationTests.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/InvalidationTests.py	2010-02-02 16:50:48 UTC (rev 108721)
+++ ZODB/trunk/src/ZEO/tests/InvalidationTests.py	2010-02-02 16:50:49 UTC (rev 108722)
@@ -130,9 +130,9 @@
     # to 'tree' until Event stop is set.  If sleep is given, sleep
     # that long after each append.  At the end, instance var .added_keys
     # is a list of the ints the thread believes it added successfully.
-    def __init__(self, db, stop, threadnum, commitdict,
+    def __init__(self, testcase, db, stop, threadnum, commitdict,
                  startnum, step=2, sleep=None):
-        TestThread.__init__(self)
+        TestThread.__init__(self, testcase)
         self.db = db
         self.stop = stop
         self.threadnum = threadnum
@@ -173,9 +173,9 @@
     # more than 25 objects so that it can test code that runs vote
     # in a separate thread when it modifies more than 25 objects.
 
-    def __init__(self, db, stop, threadnum, commitdict, startnum,
+    def __init__(self, test, db, stop, threadnum, commitdict, startnum,
                  step=2, sleep=None):
-        TestThread.__init__(self)
+        TestThread.__init__(self, test)
         self.db = db
         self.stop = stop
         self.threadnum = threadnum
@@ -361,8 +361,8 @@
 
         # Run two threads that update the BTree
         cd = {}
-        t1 = self.StressThread(db1, stop, 1, cd, 1)
-        t2 = self.StressThread(db2, stop, 2, cd, 2)
+        t1 = self.StressThread(self, db1, stop, 1, cd, 1)
+        t2 = self.StressThread(self, db2, stop, 2, cd, 2)
         self.go(stop, cd, t1, t2)
 
         while db1.lastTransaction() != db2.lastTransaction():
@@ -391,7 +391,7 @@
 
         # Run threads that update the BTree
         cd = {}
-        threads = [self.StressThread(dbs[i], stop, i, cd, i, n)
+        threads = [self.StressThread(self, dbs[i], stop, i, cd, i, n)
                    for i in range(n)]
         self.go(stop, cd, *threads)
 
@@ -418,8 +418,8 @@
 
         # Run two threads that update the BTree
         cd = {}
-        t1 = self.StressThread(db1, stop, 1, cd, 1, sleep=0.01)
-        t2 = self.StressThread(db1, stop, 2, cd, 2, sleep=0.01)
+        t1 = self.StressThread(self, db1, stop, 1, cd, 1, sleep=0.01)
+        t2 = self.StressThread(self, db1, stop, 2, cd, 2, sleep=0.01)
         self.go(stop, cd, t1, t2)
 
         cn = db1.open()
@@ -447,9 +447,9 @@
         # at the same time.
 
         cd = {}
-        t1 = self.StressThread(db1, stop, 1, cd, 1, 3)
-        t2 = self.StressThread(db2, stop, 2, cd, 2, 3, 0.01)
-        t3 = self.StressThread(db2, stop, 3, cd, 3, 3, 0.01)
+        t1 = self.StressThread(self, db1, stop, 1, cd, 1, 3)
+        t2 = self.StressThread(self, db2, stop, 2, cd, 2, 3, 0.01)
+        t3 = self.StressThread(self, db2, stop, 3, cd, 3, 3, 0.01)
         self.go(stop, cd, t1, t2, t3)
 
         while db1.lastTransaction() != db2.lastTransaction():
@@ -485,9 +485,9 @@
         # at the same time.
 
         cd = {}
-        t1 = LargeUpdatesThread(db1, stop, 1, cd, 1, 3, 0.02)
-        t2 = LargeUpdatesThread(db2, stop, 2, cd, 2, 3, 0.01)
-        t3 = LargeUpdatesThread(db2, stop, 3, cd, 3, 3, 0.01)
+        t1 = LargeUpdatesThread(self, db1, stop, 1, cd, 1, 3, 0.02)
+        t2 = LargeUpdatesThread(self, db2, stop, 2, cd, 2, 3, 0.01)
+        t3 = LargeUpdatesThread(self, db2, stop, 3, cd, 3, 3, 0.01)
         self.go(stop, cd, t1, t2, t3)
 
         while db1.lastTransaction() != db2.lastTransaction():

Modified: ZODB/trunk/src/ZEO/tests/TestThread.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/TestThread.py	2010-02-02 16:50:48 UTC (rev 108721)
+++ ZODB/trunk/src/ZEO/tests/TestThread.py	2010-02-02 16:50:49 UTC (rev 108722)
@@ -36,11 +36,12 @@
     message.
     """
 
-    def __init__(self):
+    def __init__(self, testcase):
         threading.Thread.__init__(self)
         # In case this thread hangs, don't stop Python from exiting.
         self.setDaemon(1)
         self._exc_info = None
+        self._testcase = testcase
 
     def run(self):
         try:



More information about the checkins mailing list