uuid6-python icon indicating copy to clipboard operation
uuid6-python copied to clipboard

`test.test_uuid6.UUIDTests.test_time` fails on PyPy3.11 (extremely fragile to timing)

Open mgorny opened this issue 5 months ago • 0 comments

When running the test suite on PyPy3.11 7.3.20, the following test fails:

$ python -m unittest
.....F......................
======================================================================
FAIL: test_time (test.test_uuid6.UUIDTests.test_time)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/uuid6-python/test/test_uuid6.py", line 144, in test_time
    self.assertAlmostEqual(uuid_6.time / 10**7, uuid_1.time / 10**7, 3)
AssertionError: 13974010389.99216 != 13974010389.987282 within 3 places (0.004878997802734375 difference)

----------------------------------------------------------------------
Ran 28 tests in 0.937s

FAILED (failures=1)

FWIU it's failing because you are relying on the two calls occurring within <0.001 s, which is a very fragile assumption and PyPy isn't fast enough with this code to meet it. This test should really be mocking the system clock instead.

mgorny avatar Aug 09 '25 05:08 mgorny