[Zodb-checkins] CVS: Zope/lib/python/ZODB/tests - testTransaction.py:1.3.22.1
Casey Duncan
casey@zope.com
Wed, 27 Mar 2002 15:52:00 -0500
Update of /cvs-repository/Zope/lib/python/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv22094/lib/python/ZODB/tests
Modified Files:
Tag: casey-death_to_index_html-branch
testTransaction.py
Log Message:
Updating branch to head for testing
=== Zope/lib/python/ZODB/tests/testTransaction.py 1.3 => 1.3.22.1 === (629/729 lines abridged)
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+"""
+Revision information:
+$Id$
+"""
+
+"""
+
+I wrote these unittests to investigate some odd transaction
+behavior when doing unittests of integrating non sub transaction
+aware objects, and to insure proper txn behavior. these
+tests test the transaction system independent of the rest of the
+zodb.
+
+you can see the method calls to a jar by passing the
+keyword arg tracing to the modify method of a dataobject.
+the value of the arg is a prefix used for tracing print calls
+to that objects jar.
+
+the number of times a jar method was called can be inspected
+by looking at an attribute of the jar that is the method
+name prefixed with a c (count/check).
+
+i've included some tracing examples for tests that i thought
+were illuminating as doc strings below.
+
+TODO
+
+ add in tests for objects which are modified multiple times,
+ for example an object that gets modified in multiple sub txns.
+
+"""
-import os
-import tempfile
import unittest
[-=- -=- -=- 629 lines omitted -=- -=- -=-]
+
+ def abort(self, *args):
+ self.check('abort')
+ self.cabort += 1
+
+ def commit(self, *args):
+ self.check('commit')
+ self.ccommit += 1
+
+ def tpc_begin(self, txn, sub=0):
+ self.check('tpc_begin')
+ self.ctpc_begin += 1
+
+ def tpc_vote(self, *args):
+ self.check('tpc_vote')
+ self.ctpc_vote += 1
+
+ def tpc_abort(self, *args):
+ self.check('tpc_abort')
+ self.ctpc_abort += 1
+
+ def tpc_finish(self, *args):
+ self.check('tpc_finish')
+ self.ctpc_finish += 1
+
+class SubTransactionJar(BasicJar):
+
+ def abort_sub(self, txn):
+ self.check('abort_sub')
+ self.cabort_sub = 1
+
+ def commit_sub(self, txn):
+ self.check('commit_sub')
+ self.ccommit_sub = 1
+
+class NoSubTransactionJar(BasicJar): pass
def test_suite():
- return unittest.makeSuite(AllTests, 'check')
-def main():
- tests = test_suite()
- runner = unittest.TextTestRunner()
- runner.run(tests)
+ return unittest.makeSuite(TransactionTests)
-if __name__ == "__main__":
- main()
+if __name__ == '__main__':
+ unittest.TextTestRunner().run(test_suite())