[Zodb-checkins] SVN: ZODB/trunk/src/persistent/tests/test_overriding_attrs.py Replace spurious dependency on ZODB / transaction w/ fake jars.

Tres Seaver tseaver at palladion.com
Thu Sep 18 18:13:04 EDT 2008


Log message for revision 91243:
  Replace spurious dependency on ZODB / transaction w/ fake jars.

Changed:
  U   ZODB/trunk/src/persistent/tests/test_overriding_attrs.py

-=-
Modified: ZODB/trunk/src/persistent/tests/test_overriding_attrs.py
===================================================================
--- ZODB/trunk/src/persistent/tests/test_overriding_attrs.py	2008-09-18 22:12:31 UTC (rev 91242)
+++ ZODB/trunk/src/persistent/tests/test_overriding_attrs.py	2008-09-18 22:13:04 UTC (rev 91243)
@@ -19,10 +19,16 @@
 $Id$
 """
 
-from persistent import Persistent
-import transaction
-from ZODB.tests.util import DB
+from persistent import Persistent # ouch!
 
+def _resettingJar():
+    from persistent.tests.utils import ResettingJar
+    return ResettingJar()
+
+def _rememberingJar():
+    from persistent.tests.utils import RememberingJar
+    return RememberingJar()
+
 class SampleOverridingGetattr(Persistent):
     """Example of overriding __getattr__
     """
@@ -52,10 +58,8 @@
 
         We'll save the object, so it can be deactivated:
 
-        >>> db = DB()
-        >>> conn = db.open()
-        >>> conn.root()['o'] = o
-        >>> transaction.commit()
+        >>> jar = _resettingJar()
+        >>> jar.add(o)
         >>> o._p_deactivate()
         >>> o._p_changed
 
@@ -66,10 +70,6 @@
 
         And we see that the object was activated before calling the
         __getattr__ method.
-
-        We always close databases after we use them:
-
-        >>> db.close()
         """
         # Don't pretend we have any special attributes.
         if name.startswith("__") and name.endswrith("__"):
@@ -118,10 +118,8 @@
         Next, we'll save the object in a database so that we can
         deactivate it:
 
-        >>> db = DB()
-        >>> conn = db.open()
-        >>> conn.root()['o'] = o
-        >>> transaction.commit()
+        >>> jar = _rememberingJar()
+        >>> jar.add(o)
         >>> o._p_deactivate()
         >>> o._p_changed
 
@@ -149,10 +147,6 @@
         0
 
         See the very important note in the comment below!
-
-        We always close databases after we use them:
-
-        >>> db.close()
         """
 
         #################################################################
@@ -220,13 +214,11 @@
         >>> 'x' in o.__dict__
         False
 
-        Next, we'll save the object in a database so that we can
+        Next, we'll give the object a "remembering" jar so we can
         deactivate it:
 
-        >>> db = DB()
-        >>> conn = db.open()
-        >>> conn.root()['o'] = o
-        >>> transaction.commit()
+        >>> jar = _rememberingJar()
+        >>> jar.add(o)
         >>> o._p_deactivate()
         >>> o._p_changed
 
@@ -242,9 +234,9 @@
         >>> o._p_changed
         1
 
-        Now, if commit:
+        Now, if fake a commit:
 
-        >>> transaction.commit()
+        >>> jar.fake_commit()
         >>> o._p_changed
         0
 
@@ -263,11 +255,6 @@
         0
         >>> o.tmp_foo
         3
-
-        We always close databases after we use them:
-
-        >>> db.close()
-
         """
 
         #################################################################
@@ -320,13 +307,11 @@
         ...
         AttributeError: x
 
-        Next, we'll save the object in a database so that we can
+        Next, we'll save the object in a jar so that we can
         deactivate it:
 
-        >>> db = DB()
-        >>> conn = db.open()
-        >>> conn.root()['o'] = o
-        >>> transaction.commit()
+        >>> jar = _rememberingJar()
+        >>> jar.add(o)
         >>> o._p_deactivate()
         >>> o._p_changed
 
@@ -347,9 +332,9 @@
         >>> o.tmp_z
         3
 
-        Now, if commit:
+        Now, if fake a commit:
 
-        >>> transaction.commit()
+        >>> jar.fake_commit()
         >>> o._p_changed
         0
 
@@ -371,10 +356,6 @@
         ...
         AttributeError: tmp_z
 
-        We always close databases after we use them:
-
-        >>> db.close()
-
         """
 
         #################################################################



More information about the Zodb-checkins mailing list