[Zope-Checkins] SVN: Zope/trunk/ Fixed ``testZODBCompat`` tests in ZopeTestCase to match modern ZODB semantics. There is no explicit contract for the time _v attributes actually get removed. The tests in question where bogus, as they didn't test database load but a class variable not affected by the transaction machinery. There's other tests in the same module testing more abort semantics that have a proper demo storage setup.

Hanno Schlichting hannosch at hannosch.eu
Sat Sep 25 11:18:59 EDT 2010


Log message for revision 116931:
  Fixed ``testZODBCompat`` tests in ZopeTestCase to match modern ZODB semantics. There is no explicit contract for the time _v attributes actually get removed. The tests in question where bogus, as they didn't test database load but a class variable not affected by the transaction machinery. There's other tests in the same module testing more abort semantics that have a proper demo storage setup.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Testing/ZopeTestCase/testZODBCompat.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2010-09-25 15:09:35 UTC (rev 116930)
+++ Zope/trunk/doc/CHANGES.rst	2010-09-25 15:18:58 UTC (rev 116931)
@@ -11,6 +11,9 @@
 Bugs Fixed
 ++++++++++
 
+- Fixed ``testZODBCompat`` tests in ZopeTestCase to match modern ZODB
+  semantics.
+
 Features Added
 ++++++++++++++
 

Modified: Zope/trunk/src/Testing/ZopeTestCase/testZODBCompat.py
===================================================================
--- Zope/trunk/src/Testing/ZopeTestCase/testZODBCompat.py	2010-09-25 15:09:35 UTC (rev 116930)
+++ Zope/trunk/src/Testing/ZopeTestCase/testZODBCompat.py	2010-09-25 15:18:58 UTC (rev 116931)
@@ -309,52 +309,21 @@
 
 class TestTransactionAbort(ZopeTestCase.ZopeTestCase):
 
+    def _getfolder(self):
+        return getattr(self.app, folder_name, None)
+
     def testTransactionAbort(self):
-        self.folder.foo = 1
-        self.assertTrue(hasattr(self.folder, 'foo'))
+        folder = self._getfolder()
+        self.assert_(folder is not None)
+        self.assert_(folder._p_jar is None)
+        transaction.savepoint()
+        self.assert_(folder._p_jar is not None)
         transaction.abort()
-        # The foo attribute is still present
-        self.assertTrue(hasattr(self.folder, 'foo'))
+        del folder
+        folder = self._getfolder()
+        self.assert_(folder is None)
 
-    def testSavepointAbort(self):
-        self.folder.foo = 1
-        self.assertTrue(hasattr(self.folder, 'foo'))
-        transaction.savepoint(optimistic=True)
-        transaction.abort()
-        # This time the abort nukes the foo attribute...
-        self.assertFalse(hasattr(self.folder, 'foo'))
 
-    def testTransactionAbortPersistent(self):
-        self.folder._p_foo = 1
-        self.assertTrue(hasattr(self.folder, '_p_foo'))
-        transaction.abort()
-        # The _p_foo attribute is still present
-        self.assertTrue(hasattr(self.folder, '_p_foo'))
-
-    def testSavepointAbortPersistent(self):
-        self.folder._p_foo = 1
-        self.assertTrue(hasattr(self.folder, '_p_foo'))
-        transaction.savepoint(optimistic=True)
-        transaction.abort()
-        # This time the abort nukes the _p_foo attribute...
-        self.assertFalse(hasattr(self.folder, '_p_foo'))
-
-    def testTransactionAbortVolatile(self):
-        self.folder._v_foo = 1
-        self.assertTrue(hasattr(self.folder, '_v_foo'))
-        transaction.abort()
-        # The _v_foo attribute is still present
-        self.assertTrue(hasattr(self.folder, '_v_foo'))
-
-    def testSavepointAbortVolatile(self):
-        self.folder._v_foo = 1
-        self.assertTrue(hasattr(self.folder, '_v_foo'))
-        transaction.savepoint(optimistic=True)
-        transaction.abort()
-        # This time the abort nukes the _v_foo attribute...
-        self.assertFalse(hasattr(self.folder, '_v_foo'))
-
-
 def test_suite():
     from unittest import TestSuite, makeSuite
     suite = TestSuite()



More information about the Zope-Checkins mailing list