Commit 5ec19b76 authored by Jeremy Hylton's avatar Jeremy Hylton

Add another init() method so cache tests can be run in a loop.

parent 723de304
...@@ -26,6 +26,11 @@ class RecalcitrantObject(Persistent): ...@@ -26,6 +26,11 @@ class RecalcitrantObject(Persistent):
def _p_deactivate(self): def _p_deactivate(self):
self.__class__.deactivations += 1 self.__class__.deactivations += 1
def init(cls):
cls.deactivations = 0
init = classmethod(init)
class RegularObject(Persistent): class RegularObject(Persistent):
deactivations = 0 deactivations = 0
...@@ -120,6 +125,7 @@ class CacheTests: ...@@ -120,6 +125,7 @@ class CacheTests:
also return when it's looked at each item, regardless of whether also return when it's looked at each item, regardless of whether
it became a ghost. it became a ghost.
>>> RecalcitrantObject.init()
>>> db = databaseFromString("<zodb>\n" >>> db = databaseFromString("<zodb>\n"
... "cache-size 4\n" ... "cache-size 4\n"
... "<mappingstorage/>\n" ... "<mappingstorage/>\n"
...@@ -138,7 +144,7 @@ class CacheTests: ...@@ -138,7 +144,7 @@ class CacheTests:
The Connection calls cacheGC() after it commits a transaction. The Connection calls cacheGC() after it commits a transaction.
Since the cache will now have more objects that it's target size, Since the cache will now have more objects that it's target size,
it will call _p_deactivate() on each RecalcitrantObject. it will call _p_deactivate() on each RecalcitrantObject.
>>> RecalcitrantObject.deactivations >>> RecalcitrantObject.deactivations
5 5
>>> [o._p_state for o in L] >>> [o._p_state for o in L]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment