Files
meta-openembedded/meta-python/recipes-devtools/python/python3-time-machine_3.6.0.bb
T
Khem Raj 38e34daeb4 python3-time-machine: Fix fuzz test failures on musl
test_localtime_and_gmtime_match_datetime and test_naive_datetime_modes
fail intermittently on musl. time-machine sets TZ to the zone key, and
musl parses keys that are also valid POSIX TZ rule strings, such as
EST5EDT, CST6CDT, GB-Eire, NZ-CHAT and W-SU, as rules instead of loading
the zone file, so libc local time disagrees with zoneinfo.

Prefix the key with a colon, which makes glibc and musl load the zone
file. With this and the musl fix for zone files with a single
transition, 120 of 120 hypothesis seeds of the full suite pass in a musl
image rootfs, against 18 failing seeds with this change alone.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
2026-11-17 21:49:52 -08:00

47 lines
2.1 KiB
BlitzBasic

SUMMARY = "Travel through time in your tests."
HOMEPAGE = "https://github.com/adamchainz/time-machine"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=fb9b93a440d3ef2fb6eeebfa59384c53"
SRCREV = "7434cabf2b539f5cb0ecfcb1e05864424acb3ee1"
PYPI_SRC_URI = "git://github.com/adamchainz/time-machine;protocol=https;branch=main;tag=${PV};destsuffix=time_machine-${PV}"
SRC_URI += "file://0001-Fix-fuzz-test-failing-for-ambiguous-datetimes.patch \
file://0002-Load-zone-files-explicitly-when-setting-TZ.patch \
"
inherit pypi python_setuptools_build_meta ptest-python-pytest
RDEPENDS:${PN} += "\
python3-tzdata \
python3-unittest \
python3-zoneinfo \
"
do_install_ptest:append() {
install -d ${D}${PTEST_PATH}/tests
cp -rf ${S}/tests/* ${D}${PTEST_PATH}/tests/
# test_destination_datetime_tzinfo_non_zoneinfo builds an aware datetime
# from dateutil's tz.gettz("America/Chicago") and expects the CST (-6h)
# offset at the 1970 epoch. OE builds /usr/share/zoneinfo in "slim" format
# (zic -b slim); dateutil's tzfile parser mishandles the pre-first-transition
# instant of a slim tzfile and returns a 0 (UTC) offset, so the epoch maps to
# 0 instead of 21600. Python's own zoneinfo reads the same file correctly, so
# this is a dateutil/slim-tzdata limitation, not a time_machine bug.
#
# test_marker_function/_and_fixture/_class/_module use the "testdir" fixture,
# provided by pytest's builtin pytester plugin. That plugin isn't autoloaded;
# upstream's pyproject.toml sets [tool.pytest.ini_options] addopts = "-p
# pytester", but that file isn't shipped into the ptest tree, so the fixture
# is unavailable and those 4 tests error out. Pass -p pytester directly.
sed -i -e "/--automake/ s|\$| -p pytester --deselect tests/test_time_machine.py::test_destination_datetime_tzinfo_non_zoneinfo|" \
${D}${PTEST_PATH}/run-ptest
}
RDEPENDS:${PN}-ptest += "\
python3-dateutil \
python3-dateutil-zoneinfo \
python3-freezegun \
python3-hypothesis \
python3-tokenize-rt \
tzdata \
"