[Zodb-checkins] CVS: Zope3/src/persistence/tests - test_cache.py:1.3

Jeremy Hylton jeremy@zope.com
Fri, 7 Mar 2003 15:20:35 -0500


Update of /cvs-repository/Zope3/src/persistence/tests
In directory cvs.zope.org:/tmp/cvs-serv27552/persistence/tests

Modified Files:
	test_cache.py 
Log Message:
Remove use of minimize() and full_sweep(), use incrgc() in all cases
but one where clear() seems good enough.

Reorganize module so helper classes are at the top.


=== Zope3/src/persistence/tests/test_cache.py 1.2 => 1.3 ===
--- Zope3/src/persistence/tests/test_cache.py:1.2	Wed Dec 25 09:12:13 2002
+++ Zope3/src/persistence/tests/test_cache.py	Fri Mar  7 15:20:35 2003
@@ -11,7 +11,24 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-import unittest, sys, time
+import unittest, time
+from persistence import Persistent
+from persistence.cache import Cache
+
+class P(Persistent):
+    pass
+
+class DM:
+    def __init__(self, cache):
+        self.called=0
+        self.cache=cache
+
+    def register(self, ob):
+        self.called += 1
+        
+    def setstate(self, ob):
+        ob.__setstate__({'x': 42})
+        self.cache.setstate(ob._p_oid, ob)
 
 class Test(unittest.TestCase):
 
@@ -77,13 +94,12 @@
                          {'ghosts': 0, 'active': 1},
                          )
         # No changed because p is modified:
-        dm.cache.minimize()
+        dm.cache.incrgc()
         self.assertEqual(dm.cache.statistics(),
                          {'ghosts': 0, 'active': 1},
                          )
-        p._p_changed=0
-        # Now the minimize should work
-        dm.cache.minimize()
+        p._p_changed = 0
+        dm.cache.clear()
         self.assertEqual(dm.cache.statistics(),
                          {'ghosts': 1, 'active': 0},
                          )
@@ -112,36 +128,15 @@
                          )
 
         p1.a=1
-        p1._p_atime=int(time.time()-5000)%86400
         p1._p_changed=0
+        p1._p_atime=int(time.time()-5000)%86400
         self.assertEqual(dm.cache.statistics(),
                          {'ghosts': 0, 'active': 1},
                          )
-        dm.cache.full_sweep()
+        dm.cache.incrgc()
         self.assertEqual(dm.cache.statistics(),
                          {'ghosts': 1, 'active': 0},
                          )
-
-
-
-
-
-from persistence import Persistent
-
-class P(Persistent): pass
-
-from persistence.cache import Cache
-
-class DM:
-    def __init__(self, cache):
-        self.called=0
-        self.cache=cache
-
-    def register(self, ob): self.called += 1
-    def setstate(self, ob):
-        ob.__setstate__({'x': 42})
-        self.cache.setstate(ob._p_oid, ob)
-
 
 def test_suite():
     loader=unittest.TestLoader()