[Zope-Checkins]
SVN: Zope/trunk/lib/python/Products/Transience/tests/testCounters.py
- Ensure that tests actually invoke conflict resolution.
michael dunstan
michael at elyt.com
Sat Sep 18 01:23:27 EDT 2004
Log message for revision 27631:
- Ensure that tests actually invoke conflict resolution.
- Updated to use transaction.commit() rather than
get_transaction().commit()
Changed:
U Zope/trunk/lib/python/Products/Transience/tests/testCounters.py
-=-
Modified: Zope/trunk/lib/python/Products/Transience/tests/testCounters.py
===================================================================
--- Zope/trunk/lib/python/Products/Transience/tests/testCounters.py 2004-09-18 03:27:57 UTC (rev 27630)
+++ Zope/trunk/lib/python/Products/Transience/tests/testCounters.py 2004-09-18 05:23:27 UTC (rev 27631)
@@ -17,18 +17,22 @@
from ZODB.POSException import ConflictError
from ZODB.FileStorage import FileStorage
from ZODB.DB import DB
+import transaction
from Products.Transience.Transience import Length2, Increaser
+# Test pattern is copied from BTrees/tests/testConflict.py
+
class Base(TestCase):
- db = None
+ storage = None
def setUp(self):
pass
def tearDown(self):
- if self.db is not None:
- self.db.close()
+ transaction.abort()
+ if self.storage is not None:
+ self.storage.close()
self.storage.cleanup()
def openDB(self):
@@ -39,15 +43,15 @@
class TestLength2(Base):
def testConflict(self):
- # this test fails on the HEAD (MVCC?)
+ # Set up database connections to provoke conflict.
self.openDB()
length = Length2(0)
r1 = self.db.open().root()
r1['ob'] = length
- get_transaction().commit()
+ transaction.commit()
- r2 = self.db.open().root()
+ r2 = self.db.open(synch=False).root()
copy = r2['ob']
# The following ensures that copy is loaded.
self.assertEqual(copy(),0)
@@ -55,40 +59,42 @@
# First transaction.
length.increment(10)
length.decrement(1)
- get_transaction().commit()
+ transaction.commit()
# Second transaction.
length = copy
length.increment(20)
length.decrement(2)
- get_transaction().commit()
+ transaction.commit()
self.assertEqual(length(), 10+20-max(1,2))
class TestIncreaser(Base):
def testConflict(self):
+
+ # Set up database connections to provoke conflict.
self.openDB()
increaser = Increaser(0)
r1 = self.db.open().root()
r1['ob'] = increaser
- get_transaction().commit()
+ transaction.commit()
- r2 = self.db.open().root()
+ r2 = self.db.open(synch=False).root()
copy = r2['ob']
# The following ensures that copy is loaded.
self.assertEqual(copy(),0)
# First transaction.
increaser.set(10)
- get_transaction().commit()
+ transaction.commit()
# Second transaction.
increaser = copy
increaser.set(20)
- get_transaction().commit()
+ transaction.commit()
self.assertEqual(increaser(), 20)
More information about the Zope-Checkins
mailing list