[Zodb-checkins] CVS: StandaloneZODB/ZODB/tests - testTransaction.py:1.6
Jeremy Hylton
jeremy@zope.com
Fri, 12 Apr 2002 14:22:46 -0400
Update of /cvs-repository/StandaloneZODB/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv21553
Modified Files:
testTransaction.py
Log Message:
Cosmetic changes to ExceptionInSubAbortSub,
including some use of assert/fail methods instead of assert stmt.
=== StandaloneZODB/ZODB/tests/testTransaction.py 1.5 => 1.6 ===
"""
-import unittest
-
from types import TupleType
+import unittest
from ZODB import Transaction
@@ -467,31 +466,32 @@
assert self.nosub1._p_jar.ctpc_abort == 1
def testExceptionInSubAbortSub(self):
-
self.sub1._p_jar = SubTransactionJar(errors='commit_sub')
-
self.sub1.modify(nojar=1)
-
get_transaction().commit(1)
self.nosub1.modify()
-
self.sub2._p_jar = SubTransactionJar(errors='abort_sub')
-
self.sub2.modify(nojar=1)
-
get_transaction().commit(1)
self.sub3.modify()
try:
get_transaction().commit()
- except TestTxnException: pass
+ except TestTxnException, err:
+ pass
+ else:
+ self.fail("expected transaction to fail")
+ # The last commit failed. If the commit_sub() method was
+ # called, then tpc_abort() should be called to abort the
+ # actual transaction. If not, then calling abort_sub() is
+ # sufficient.
if self.sub3._p_jar.ccommit_sub == 1:
- assert self.sub3._p_jar.ctpc_abort == 1
+ self.assertEqual(self.sub3._p_jar.ctpc_abort, 1)
else:
- assert self.sub3._p_jar.cabort_sub == 1
+ self.assertEqual(self.sub3._p_jar.cabort_sub, 1)
### XXX
def BUGtestExceptionInSubTpcBegin(self):
@@ -603,15 +603,12 @@
self.ccommit_sub = 0
def check(self, method):
-
if self.tracing:
print '%s calling method %s'%(str(self.tracing),method)
-
- if (type(self.errors) is TupleType and method in self.errors) or \
- method == self.errors:
-
- raise TestTxnException(" error %s"%method)
+ if ((type(self.errors) is TupleType and method in self.errors)
+ or method == self.errors):
+ raise TestTxnException("error %s" % method)
## basic jar txn interface