Skip to content

Test suite manipulates system clock time, breaking other tests #162280

Open

Description

@rossburton

Bug report

We run the python test suite in parallel for speed reasons, but test_time.py:test_monotonic_settime() sets the realtime clock to an hour ago (-3600s) for a moment and then resets it.

I suspect, this is the cause for occasional failures in the tests:

FAIL: test_extractall_none_mtime (test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mtime) (path=PosixPath('/var/volatile/tmp/test_python_0
c2fdsmi/test_python_17795√¶/@test_17795_tmp√¶-tardir/extractall_none/gnu/123/123/123/123/123'))
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.14/test/test_tarfile.py", line 3581, in test_extractall_none_mtime
    self.assertGreaterEqual(path.stat().st_mtime, now)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 1794589993.9077852 not greater than or equal to 1794593593.9003344

Note that the difference between those two timestamps is 3599.9925492s. I was scratching my head as to how a parent directory would be created after a file inside it, but I suspect test_tarfile and test_time were running in parallel.

I'd suggest that manipulating the system time be guarded with a feature check, on the grounds that changing the system time has effects outside of the test suite. If a developer was running the tests whilst doing other work, hitting that window could cause data loss.

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions