[Zodb-checkins] CVS: ZODB3/ZODB/tests - testCache.py:1.12
Jeremy Hylton
jeremy@zope.com
Tue, 1 Apr 2003 14:23:26 -0500
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv2345
Modified Files:
testCache.py
Log Message:
Minimal fixes to make these tests work again.
The cache behaves differently now; it doesn't keep objects alive
artificially. We should write some new tests that verify behavior
with objects that are kept alive by external references.
=== ZODB3/ZODB/tests/testCache.py 1.11 => 1.12 ===
--- ZODB3/ZODB/tests/testCache.py:1.11 Tue Apr 1 13:06:04 2003
+++ ZODB3/ZODB/tests/testCache.py Tue Apr 1 14:23:25 2003
@@ -170,9 +170,6 @@
# not bother to check this
def checkSize(self):
- # XXX need to fix
- return
-
self.assertEqual(self.db.cacheSize(), 0)
self.assertEqual(self.db.cacheDetailSize(), [])
@@ -183,19 +180,11 @@
for i in range(CONNS):
self.noodle_new_connection()
- self.assertEquals(self.db.cacheSize(), CACHE_SIZE * CONNS)
- details = self.db.cacheDetailSize()
- self.assertEquals(len(details), CONNS)
- for d in details:
- self.assertEquals(d['ngsize'], CACHE_SIZE)
- # the root is also in the cache as ghost, because
- # the connection holds a reference to it
- self.assertEquals(d['size'], CACHE_SIZE + 1)
+ # The DB cacheSize() method returns the number of non-ghost
+ # objects, which should be zero.
+ self.assertEquals(self.db.cacheSize(), 0)
def checkDetail(self):
- # XXX need to fix
- return
-
CACHE_SIZE = 10
self.db.setCacheSize(CACHE_SIZE)
@@ -203,22 +192,15 @@
for i in range(CONNS):
self.noodle_new_connection()
- for klass, count in self.db.cacheDetail():
- print klass, count
- if klass.endswith('MinPO'):
- self.assertEqual(count, CONNS * CACHE_SIZE)
- if klass.endswith('PersistentMapping'):
- # one root per connection
- self.assertEqual(count, CONNS)
+ # the only thing in the cache is the root objects,
+ # which are referenced explicitly by the connection.
+ [(klass, count)] = self.db.cacheDetail()
+ self.assertEqual(klass, "Persistence.PersistentMapping")
+ self.assertEqual(count, CONNS)
for details in self.db.cacheExtremeDetail():
- print details
- # one dict per object. keys:
- if details['klass'].endswith('PersistentMapping'):
- self.assertEqual(details['state'], None)
- else:
- self.assert_(details['klass'].endswith('MinPO'))
- self.assertEqual(details['state'], 0)
+ self.assertEqual(details["klass"], "Persistence.PersistentMapping")
+ self.assertEqual(details['state'], None)
class StubDataManager:
def setklassstate(self, object):