Skip to content

Commit

Permalink
Fix test to no longer depend on what time is
Browse files Browse the repository at this point in the history
There's no reason to care.

(And a change in db root-object setup shifted the old test times.)
  • Loading branch information
Jim Fulton committed Jul 23, 2016
1 parent 61af558 commit dedd5a2
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/ZODB/FileStorage/iterator.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ special tests.

We'll make some assertions about time, so we'll take it over:

>>> now = 1229959248
>>> def faux_time():
... global now
... now += 0.1
... return now
>>> import time
>>> time_time = time.time
>>> if isinstance(time,type):
... time.time = staticmethod(faux_time) # Jython
... else:
... time.time = faux_time

Commit a bunch of transactions:

>>> import ZODB.FileStorage, transaction
Expand Down Expand Up @@ -63,28 +51,32 @@ seems best and set the next record to that:
>>> it.close()

>>> it = ZODB.FileStorage.FileIterator('data.fs', tids[1])
Scan forward data.fs:<OFFSET> looking for '\x03z\xbd\xd8\xd06\x9c\xcc'
... # doctest: +ELLIPSIS
Scan forward data.fs:<OFFSET> looking for '...'
>>> it.next().tid == tids[1]
True

>>> it.close()

>>> it = ZODB.FileStorage.FileIterator('data.fs', tids[30])
Scan forward data.fs:<OFFSET> looking for '\x03z\xbd\xd8\xdc\x96.\xcc'
... # doctest: +ELLIPSIS
Scan forward data.fs:<OFFSET> looking for '...'
>>> it.next().tid == tids[30]
True

>>> it.close()

>>> it = ZODB.FileStorage.FileIterator('data.fs', tids[70])
Scan backward data.fs:<OFFSET> looking for '\x03z\xbd\xd8\xed\xa7>\xcc'
... # doctest: +ELLIPSIS
Scan backward data.fs:<OFFSET> looking for '...'
>>> it.next().tid == tids[70]
True

>>> it.close()

>>> it = ZODB.FileStorage.FileIterator('data.fs', tids[-2])
Scan backward data.fs:<OFFSET> looking for '\x03z\xbd\xd8\xfa\x06\xd0\xcc'
... # doctest: +ELLIPSIS
Scan backward data.fs:<OFFSET> looking for '...'
>>> it.next().tid == tids[-2]
True

Expand Down Expand Up @@ -118,14 +110,16 @@ starting point, or just pick up where another iterator left off:
>>> it.close()

>>> it = ZODB.FileStorage.FileIterator('data.fs', tids[50], pos=poss[50])
Scan backward data.fs:<OFFSET> looking for '\x03z\xbd\xd8\xe5\x1e\xb6\xcc'
... # doctest: +ELLIPSIS
Scan backward data.fs:<OFFSET> looking for '...'
>>> it.next().tid == tids[50]
True

>>> it.close()

>>> it = ZODB.FileStorage.FileIterator('data.fs', tids[49], pos=poss[50])
Scan backward data.fs:<OFFSET> looking for '\x03z\xbd\xd8\xe4\xb1|\xcc'
... # doctest: +ELLIPSIS
Scan backward data.fs:<OFFSET> looking for '...'
>>> it.next().tid == tids[49]
True

Expand Down Expand Up @@ -172,5 +166,4 @@ Even if we write more transactions:

.. Cleanup

>>> time.time = time_time
>>> db.close()

0 comments on commit dedd5a2

Please sign in to comment.