Repository navigation
test_zipfile can fail if SOURCE_DATE_EPOCH is set #154948
Copy link
Copy link
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
It is common to build Python with SOURCE_DATE_EPOCH set to some stable timestamp, allowing the Python build to be reproduced later (by setting the same timestamp). It's also common to run the Python test suite when you build Python.
In GH-152831, I set SOURCE_DATE_EPOCH, so that multiple builds of Python would be as similar as possible. But setting this before running the Python test suite breaks test_zipfile.
It's probably OK for test_zipfile to skip tests in this scenario, but if its the test we run in GitHub CI, that's probably not OK. For now, I have no other reason to set it.
$ SOURCE_DATE_EPOCH=1785326513 ./python -m test test_zipfile
...
======================================================================
FAIL: test_repack_removed_bytes_between_files (test.test_zipfile.test_core.ZstdRepackTests.test_repack_removed_bytes_between_files) (removed=[2])
Should not remove bytes between local file entries.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/stefanor/git/upstream/cpython/Lib/test/test_zipfile/test_core.py", line 2282, in test_repack_removed_bytes_between_files
self.assertEqual(
~~~~~~~~~~~~~~~~^
[comparable_zinfo(zi) for zi in zh.infolist()],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[comparable_zinfo(zi) for zi in expected_zinfos],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
AssertionError: Lists differ: [{'or[82 chars] 1, 52), 'compress_type': 93, 'compress_level'[678 chars] 62}] != [{'or[82 chars] 1, 53), 'compress_type': 93, 'compress_level'[678 chars] 62}]
First differing element 0:
{'ori[81 chars] 1, 52), 'compress_type': 93, 'compress_level'[268 chars]: 55}
{'ori[81 chars] 1, 53), 'compress_type': 93, 'compress_level'[268 chars]: 55}
[{'CRC': 1821039217,
'comment': b'',
'compress_level': None,
'compress_size': 64,
'compress_type': 93,
'create_system': 3,
'create_version': 63,
- 'date_time': (2026, 7, 29, 12, 1, 52),
? ^
+ 'date_time': (2026, 7, 29, 12, 1, 53),
? ^
'external_attr': 25165824,
'extra': b'',
'extract_version': 63,
'file_size': 55,
'filename': 'file0.txt',
'flag_bits': 2048,
'header_offset': 0,
'internal_attr': 0,
'orig_filename': 'file0.txt',
'reserved': 0,
'volume': 0},
{'CRC': 2493679103,
'comment': b'',
'compress_level': None,
'compress_size': 71,
'compress_type': 93,
'create_system': 3,
'create_version': 63,
- 'date_time': (2026, 7, 29, 12, 1, 52),
? ^
+ 'date_time': (2026, 7, 29, 12, 1, 53),
? ^
'external_attr': 25165824,
'extra': b'',
'extract_version': 63,
'file_size': 62,
'filename': 'file1.txt',
'flag_bits': 2048,
'header_offset': 116,
'internal_attr': 0,
'orig_filename': 'file1.txt',
'reserved': 0,
'volume': 0}]
----------------------------------------------------------------------
Ran 589 tests in 10.300s
FAILED (failures=50, skipped=3)(I skipped 49 similar failures in the output)
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Activity
yassinbahri commentedon Jul 31, 2026
can I work on this?
gh-154948: Fix `test_zipfile` failure when `SOURCE_DATE_EPOCH` is set (…
[3.15] gh-154948: Fix `test_zipfile` failure when `SOURCE_DATE_EPOCH`…
Set SOURCE_DATE_EPOCH again (now that pythonGH-154948 is fixed)
Set SOURCE_DATE_EPOCH again (now that pythonGH-154948 is fixed)
pythongh-154948: Fix `test_zipfile` failure when `SOURCE_DATE_EPOCH` …