test_dirnode.py: simplejson-1.7.1 incorrectly rounds floats to two decimal places. Don't let this bug flunk the timestamp test.

This commit is contained in:
Brian Warner 2008-02-11 17:35:17 -07:00
parent 7123c9d875
commit 09cf1e2a8a

View File

@ -333,8 +333,15 @@ class Dirnode(unittest.TestCase, testutil.ShouldFailMixin):
def _start(res): def _start(res):
self._start_timestamp = time.time() self._start_timestamp = time.time()
d.addCallback(_start) d.addCallback(_start)
# simplejson-1.7.1 (as shipped on Ubuntu 'gutsy') rounds all
# floats to hundredeths (it uses str(num) instead of repr(num)).
# simplejson-1.7.3 does not have this bug. To prevent this bug
# from causing the test to fail, stall for more than a few
# hundrededths of a second.
d.addCallback(self.stall, 0.1)
d.addCallback(lambda res: n.add_file("timestamps", d.addCallback(lambda res: n.add_file("timestamps",
upload.Data("stamp me"))) upload.Data("stamp me")))
d.addCallback(self.stall, 0.1)
def _stop(res): def _stop(res):
self._stop_timestamp = time.time() self._stop_timestamp = time.time()
d.addCallback(_stop) d.addCallback(_stop)