[Zodb-checkins] CVS: ZODB/src/BTrees/tests - test_compare.py:1.4 testConflict.py:1.20 testBTrees.py:1.55

Jeremy Hylton jeremy at zope.com
Fri Apr 16 11:58:45 EDT 2004


Update of /cvs-repository/ZODB/src/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv11088/src/BTrees/tests

Modified Files:
	test_compare.py testConflict.py testBTrees.py 
Log Message:
Replace use of builtin get_transaction() with explicit transaction module.


=== ZODB/src/BTrees/tests/test_compare.py 1.3 => 1.4 ===
--- ZODB/src/BTrees/tests/test_compare.py:1.3	Thu Feb 26 19:31:50 2004
+++ ZODB/src/BTrees/tests/test_compare.py	Fri Apr 16 11:58:13 2004
@@ -15,11 +15,12 @@
 
 import unittest
 
+from BTrees.OOBTree import OOBucket as Bucket, OOSet as Set
+
+import transaction
 from ZODB.MappingStorage import MappingStorage
 from ZODB.DB import DB
 
-from BTrees.OOBTree import OOBucket as Bucket, OOSet as Set
-
 class CompareTest(unittest.TestCase):
 
     s = "A string with hi-bit-set characters: \700\701"
@@ -35,7 +36,7 @@
         root = self.db.open().root()
         self.bucket = root["bucket"] = Bucket()
         self.set = root["set"] = Set()
-        get_transaction().commit()
+        transaction.commit()
 
     def tearDown(self):
         self.assert_(self.bucket._p_changed != 2)


=== ZODB/src/BTrees/tests/testConflict.py 1.19 => 1.20 ===
--- ZODB/src/BTrees/tests/testConflict.py:1.19	Wed Apr 14 16:45:36 2004
+++ ZODB/src/BTrees/tests/testConflict.py	Fri Apr 16 11:58:13 2004
@@ -19,6 +19,7 @@
 from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
 from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
 
+import transaction
 from ZODB.POSException import ConflictError
 
 class Base:
@@ -27,7 +28,7 @@
     storage = None
 
     def tearDown(self):
-        get_transaction().abort()
+        transaction.abort()
         del self.t
         if self.storage is not None:
             self.storage.close()
@@ -75,7 +76,7 @@
 
         r1 = self.db.open().root()
         r1["t"] = self.t
-        get_transaction().commit()
+        transaction.commit()
 
         r2 = self.db.open().root()
         copy = r2["t"]
@@ -84,10 +85,10 @@
         self.assertEqual(self.t._p_serial, copy._p_serial)
 
         self.t.update({1:2, 2:3})
-        get_transaction().commit()
+        transaction.commit()
 
         copy.update({3:4})
-        get_transaction().commit()
+        transaction.commit()
 
 
     def testMergeDelete(self):
@@ -427,7 +428,7 @@
 
         r1 = self.db.open().root()
         r1["t"] = self.t
-        get_transaction().commit()
+        transaction.commit()
 
         r2 = self.db.open().root()
         copy = r2["t"]
@@ -437,10 +438,10 @@
         self.assertEqual(self.t._p_serial, copy._p_serial)
 
         self.t.update({1:2, 2:3})
-        get_transaction().commit()
+        transaction.commit()
 
         copy.update({3:4})
-        get_transaction().commit()  # if this doesn't blow up
+        transaction.commit()  # if this doesn't blow up
         list(copy.values())         # and this doesn't either, then fine
 
     def testBucketSplitConflict(self):
@@ -467,7 +468,7 @@
 
         r1 = self.db.open().root()
         r1["t"] = self.t
-        get_transaction().commit()
+        transaction.commit()
 
         r2 = self.db.open(synch=False).root()
         copy = r2["t"]
@@ -499,7 +500,7 @@
         self.assertEqual(state[0][3], 75)
         self.assertEqual(state[0][5], 120)
 
-        get_transaction().commit()
+        transaction.commit()
 
         # In the other transaction, add 3 values near the tail end of bucket1.
         # This doesn't cause a split.
@@ -517,8 +518,8 @@
         self.assertEqual(state[0][1], 60)
         self.assertEqual(state[0][3], 120)
 
-        self.assertRaises(ConflictError, get_transaction().commit)
-        get_transaction().abort()   # horrible things happen w/o this
+        self.assertRaises(ConflictError, transaction.commit)
+        transaction.abort()   # horrible things happen w/o this
 
     def testEmptyBucketConflict(self):
         # Tests that an emptied bucket *created by* conflict resolution is
@@ -544,7 +545,7 @@
 
         r1 = self.db.open().root()
         r1["t"] = self.t
-        get_transaction().commit()
+        transaction.commit()
 
         r2 = self.db.open(synch=False).root()
         copy = r2["t"]
@@ -568,7 +569,7 @@
         self.assertEqual(state[0][1], 60)
         self.assertEqual(state[0][3], 120)
 
-        get_transaction().commit()
+        transaction.commit()
 
         # In the other transaction, delete the other half of bucket 1.
         b = copy
@@ -589,8 +590,8 @@
         # create an "insane" BTree (a legit BTree cannot contain an empty
         # bucket -- it contains NULL pointers the BTree code doesn't
         # expect, and segfaults result).
-        self.assertRaises(ConflictError, get_transaction().commit)
-        get_transaction().abort()   # horrible things happen w/o this
+        self.assertRaises(ConflictError, transaction.commit)
+        transaction.abort()   # horrible things happen w/o this
 
 
     def testEmptyBucketNoConflict(self):
@@ -616,7 +617,7 @@
 
         r1 = self.db.open().root()
         r1["t"] = self.t
-        get_transaction().commit()
+        transaction.commit()
 
         r2 = self.db.open().root()
         copy = r2["t"]
@@ -639,7 +640,7 @@
         self.assertEqual(state[0][1], 60)
         self.assertEqual(state[0][3], 120)
 
-        get_transaction().commit()
+        transaction.commit()
 
         # In the other transaction, delete bucket 2.
         b = copy
@@ -655,7 +656,7 @@
         self.assertEqual(state[0][1], 60)
 
         # This shouldn't create a ConflictError.
-        get_transaction().commit()
+        transaction.commit()
         # And the resulting BTree shouldn't have internal damage.
         b._check()
 
@@ -685,7 +686,7 @@
         self.openDB()
         r1 = self.db.open().root()
         r1["t"] = self.t
-        get_transaction().commit()
+        transaction.commit()
 
         r2 = self.db.open(synch=False).root()
         copy = r2["t"]
@@ -699,16 +700,16 @@
 
         for k in range(200, 300, 4):
             self.t[k] = k
-        get_transaction().commit()
+        transaction.commit()
 
         for k in range(0, 60, 4):
             del copy[k]
 
         try:
-            get_transaction().commit()
+            transaction.commit()
         except ConflictError, detail:
             self.assert_(str(detail).startswith('database conflict error'))
-            get_transaction().abort()
+            transaction.abort()
         else:
             self.fail("expected ConflictError")
 


=== ZODB/src/BTrees/tests/testBTrees.py 1.54 => 1.55 ===
--- ZODB/src/BTrees/tests/testBTrees.py:1.54	Fri Nov 28 11:44:45 2003
+++ ZODB/src/BTrees/tests/testBTrees.py	Fri Apr 16 11:58:13 2004
@@ -21,6 +21,7 @@
 
 from BTrees.check import check
 
+import transaction
 from ZODB import DB
 from ZODB.MappingStorage import MappingStorage
 
@@ -56,7 +57,7 @@
             root = None
             root = self._getRoot()
             root[i] = t
-            get_transaction().commit()
+            transaction.commit()
 
             root2 = self._getRoot()
             if hasattr(t, 'items'):
@@ -73,11 +74,11 @@
             self._populate(t, i)
             root = self._getRoot()
             root[i] = t
-            get_transaction().commit()
+            transaction.commit()
 
             root2 = self._getRoot()
             root2[i]._p_deactivate()
-            get_transaction().commit()
+            transaction.commit()
             if hasattr(t, 'items'):
                 self.assertEqual(list(root2[i].items()) , list(t.items()))
             else:




More information about the Zodb-checkins mailing list