MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_source_mtime_long_long

Function test_source_mtime_long_long

testing/test_assertrewrite.py:1322–1341  ·  view source on GitHub ↗

Support modification dates after 2038 in rewritten files (#4903). pytest would crash with: fp.write(struct.pack("<ll", mtime, size)) E struct.error: argument out of range

(pytester: Pytester, offset)

Source from the content-addressed store, hash-verified

1320)
1321@pytest.mark.parametrize("offset", [-1, +1])
1322def test_source_mtime_long_long(pytester: Pytester, offset) -> None:
1323 """Support modification dates after 2038 in rewritten files (#4903).
1324
1325 pytest would crash with:
1326
1327 fp.write(struct.pack("<ll", mtime, size))
1328 E struct.error: argument out of range
1329 """
1330 p = pytester.makepyfile(
1331 """
1332 def test(): pass
1333 """
1334 )
1335 # use unsigned long timestamp which overflows signed long,
1336 # which was the cause of the bug
1337 # +1 offset also tests masking of 0xFFFFFFFF
1338 timestamp = 2 ** 32 + offset
1339 os.utime(str(p), (timestamp, timestamp))
1340 result = pytester.runpytest()
1341 assert result.ret == 0
1342
1343
1344def test_rewrite_infinite_recursion(

Callers

nothing calls this directly

Calls 2

makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected