[Zodb-checkins] CVS: Zope/lib/python/ZODB/tests - testConnection.py:1.12

Tim Peters tim.one at comcast.net
Thu Apr 15 21:08:44 EDT 2004


Update of /cvs-repository/Zope/lib/python/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv10213/lib/python/ZODB/tests

Modified Files:
	testConnection.py 
Log Message:
Finally changed Connection to use the new transaction join API.  This
essentially means a connection keep track of which objects from
the connection are modified, instead of transactions keeping track of that.
A good consequence hasn't yet been implemented:  if a connection is
closed with modifications still pending, we can detect that efficiently
now, and complain.


=== Zope/lib/python/ZODB/tests/testConnection.py 1.11 => 1.12 ===
--- Zope/lib/python/ZODB/tests/testConnection.py:1.11	Fri Apr  9 07:11:32 2004
+++ Zope/lib/python/ZODB/tests/testConnection.py	Thu Apr 15 21:08:12 2004
@@ -21,6 +21,7 @@
 from ZODB.config import databaseFromString
 from ZODB.utils import p64, u64
 from ZODB.tests.warnhook import WarningsHook
+import transaction
 
 class ConnectionDotAdd(unittest.TestCase):
 
@@ -31,6 +32,9 @@
         self.datamgr._setDB(self.db)
         self.transaction = StubTransaction()
 
+    def tearDown(self):
+        transaction.abort()
+
     def check_add(self):
         from ZODB.POSException import InvalidObjectReference
         obj = StubObject()
@@ -61,7 +65,7 @@
         obj = StubObject()
         self.datamgr.add(obj)
         oid = obj._p_oid
-        self.datamgr.abort(obj, self.transaction)
+        self.datamgr.abort(self.transaction)
         self.assert_(obj._p_oid is None)
         self.assert_(obj._p_jar is None)
         self.assertRaises(KeyError, self.datamgr.get, oid)
@@ -85,9 +89,8 @@
         obj = StubObject()
         self.datamgr.add(obj)
         oid = obj._p_oid
-
         self.datamgr.tpc_begin(self.transaction)
-        self.datamgr.commit(obj, self.transaction)
+        self.datamgr.commit(self.transaction)
         # Let's pretend something bad happened here.
         self.datamgr.tpc_abort(self.transaction)
         self.assert_(obj._p_oid is None)
@@ -99,9 +102,8 @@
         obj = StubObject()
         self.datamgr.add(obj)
         oid = obj._p_oid
-
         self.datamgr.tpc_begin(self.transaction)
-        self.datamgr.commit(obj, self.transaction)
+        self.datamgr.commit(self.transaction)
         self.datamgr.tpc_finish(self.transaction)
         self.assert_(obj._p_oid is oid)
         self.assert_(obj._p_jar is self.datamgr)
@@ -115,9 +117,9 @@
     def checkModifyOnGetstate(self):
         subobj = StubObject()
         obj = ModifyOnGetStateObject(subobj)
-
+        self.datamgr.add(obj)
         self.datamgr.tpc_begin(self.transaction)
-        self.datamgr.commit(obj, self.transaction)
+        self.datamgr.commit(self.transaction)
         self.datamgr.tpc_finish(self.transaction)
         storage = self.db._storage
         self.assert_(obj._p_oid in storage._stored, "object was not stored")
@@ -175,7 +177,7 @@
 
         The object is a ghost.
 
-        >>> obj._p_state 
+        >>> obj._p_state
         -1
 
         And multiple calls with the same oid, return the same object.
@@ -451,7 +453,7 @@
 
 class ErrorOnGetstateException(Exception):
     pass
-    
+
 class ErrorOnGetstateObject(Persistent):
 
     def __getstate__(self):
@@ -563,7 +565,6 @@
 
     def invalidate(self, transaction, dict_with_oid_keys, connection):
         pass
-
 
 def test_suite():
     s = unittest.makeSuite(ConnectionDotAdd, 'check')




More information about the Zodb-checkins mailing list