Skip to content

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

@mgorny

Description

@mgorny

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions