[ZODB-Dev] Re: Some unit tests leave an unclean transaction

Marius Gedminas mgedmin at b4net.lt
Mon Apr 26 14:55:34 EDT 2004


On Mon, Apr 26, 2004 at 09:44:23PM +0300, Marius Gedminas wrote:
> Some BTree unit tests (BTrees.tests.test_compare.CompareTest) leave the
> transaction in an unclean state.  This has not been a problem so far,
> but is generally a bad thing to do.  I suggest adding a call to
> transaction.abort in tearDown:
> 
> --- src/BTrees/tests/test_compare.py    (revision 785)
> +++ src/BTrees/tests/test_compare.py    (working copy)
> @@ -41,6 +41,7 @@
>      def tearDown(self):
>          self.assert_(self.bucket._p_changed != 2)
>          self.assert_(self.set._p_changed != 2)
> +        transaction.abort()
> 
>      def assertUE(self, callable, *args):
>          self.assertRaises(UnicodeError, callable, *args)
> 
> 
> At least one of ZODB doctests (ZODB.tests.test_cache.CacheTests.test_cache)
> does the same thing.

--- src/ZODB/tests/test_cache.py        (revision 785)
+++ src/ZODB/tests/test_cache.py        (working copy)
@@ -56,6 +56,10 @@
     def test_cache(self):
         r"""Test basic cache methods.

+        Let's start with a clean transaction
+
+        >>> transaction.abort()
+
         >>> RegularObject.init()
         >>> db = databaseFromString("<zodb>\n"
         ...                         "cache-size 4\n"
@@ -114,6 +118,10 @@
         >>> RegularObject.deactivations
         10

+        Clean up
+
+        >>> transaction.abort()
+
         """

     def test_cache_gc_recalcitrant(self):


Marius Gedminas
-- 
If you want to trick a pointy-haired boss into letting you write software in
Lisp, you could try telling him it's XML.
		-- http://www.paulgraham.com/icad.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20040426/cd063194/attachment.bin


More information about the ZODB-Dev mailing list