[Zodb-checkins] CVS: ZODB3/ZODB/tests - RevisionStorage.py:1.4.2.7
Tim Peters
cvs-admin at zope.org
Mon Dec 1 10:09:23 EST 2003
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv30700/ZODB/tests
Modified Files:
Tag: ZODB3-mvcc-2-branch
RevisionStorage.py
Log Message:
checkLoadNonCurrent(): Inserted snoozes sufficient so that this test
always passes on Windows (instead of almost always failing).
=== ZODB3/ZODB/tests/RevisionStorage.py 1.4.2.6 => 1.4.2.7 ===
--- ZODB3/ZODB/tests/RevisionStorage.py:1.4.2.6 Tue Nov 25 12:36:25 2003
+++ ZODB3/ZODB/tests/RevisionStorage.py Mon Dec 1 10:09:21 2003
@@ -14,7 +14,7 @@
"""Check loadSerial() on storages that support historical revisions."""
from ZODB.tests.MinPO import MinPO
-from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle
+from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle, snooze
from ZODB.utils import p64, u64
ZERO = '\0'*8
@@ -40,14 +40,23 @@
revs = []
revid = None
for i in range(10):
+ # We need to ensure that successive timestamps are at least
+ # two apart, so that a timestamp exists that's unambiguously
+ # between successive timestamps. Each call to snooze()
+ # guarantees that the next timestamp will be at least one
+ # larger (and probably much more than that) than the previous
+ # one.
+ snooze()
+ snooze()
revid = self._dostore(oid, revid, data=MinPO(i))
revs.append(self._storage.loadEx(oid, ""))
-
+
prev = u64(revs[0][2])
for i in range(1, 10):
tid = revs[i][2]
cur = u64(tid)
middle = prev + (cur - prev) / 2
+ assert prev < middle < cur # else the snooze() trick failed
prev = cur
t = self._storage.loadNonCurrent(oid, p64(middle))
self.assert_(t is not None)
@@ -61,12 +70,12 @@
self.assertRaises(KeyError, self._storage.loadNonCurrent,
oid, p64(0))
-
+
revid1 = self._dostore(oid, data=MinPO(1))
-
+
self.assertEqual(self._storage.loadNonCurrent(oid, p64(0)), None)
self.assertEqual(self._storage.loadNonCurrent(oid, revid1), None)
-
+
cur = p64(u64(revid1) + 1)
data, serial, start, end = self._storage.loadNonCurrent(oid, cur)
self.assertEqual(zodb_unpickle(data), MinPO(1))
More information about the Zodb-checkins
mailing list