Skip to content

Commit

Permalink
windows: fix failures due to low-precision of time.time()
Browse files Browse the repository at this point in the history
This fixes the following random failure:

Failure in test checkBaseHistory (ZODB.tests.testDemoStorage.DemoStorageTests)
Traceback (most recent call last):
  File "unittest\case.py", line 384, in _executeTestPart
    function()
  File "ZODB\tests\testDemoStorage.py", line 96, in checkBaseHistory
    self._checkHistory(base_only())
  File "ZODB\tests\HistoryStorage.py", line 46, in _checkHistory
    self.assertLess(a, b)
  File "unittest\case.py", line 1026, in assertLess
    self.fail(self._formatMessage(msg, standardMsg))
  File "unittest\case.py", line 508, in fail
    raise self.failureException(msg)
AssertionError: 1465433823.260304 not less than 1465433823.260304
  • Loading branch information
jmuchemb committed Jun 11, 2016
1 parent 53c31a5 commit f08b40e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ZODB/tests/HistoryStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
all these tests.
"""

from time import time
import sys
from time import time, sleep
from ZODB.tests.MinPO import MinPO

class HistoryStorage:
Expand All @@ -31,6 +32,9 @@ def _checkHistory(self, data):
self.assertRaises(KeyError,self._storage.history,oid)
revids = [None]
for data in data:
if sys.platform == 'win32':
# time.time() has a precision of 1ms on Windows.
sleep(0.001)
revids.append(self._dostore(oid, revids[-1], MinPO(data)))
revids.reverse()
del revids[-1]
Expand Down

0 comments on commit f08b40e

Please sign in to comment.