From 8a984c45656a6e0f7eeabc62c574e088f339759b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 28 May 2024 14:06:13 +0200 Subject: [PATCH] Fix tests with Python 3.13.0b1 --- 12698.patch | 30 ++++++++++++++++++++++++++++++ python-pip.spec | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 12698.patch diff --git a/12698.patch b/12698.patch new file mode 100644 index 0000000..6251567 --- /dev/null +++ b/12698.patch @@ -0,0 +1,30 @@ +From a2b23ffd477dcd90de6f1cb1f4cb75e0229d0e16 Mon Sep 17 00:00:00 2001 +From: Richard Si +Date: Sat, 11 May 2024 13:26:30 -0400 +Subject: [PATCH] Also patch time.time_ns() in unit tests + +The logging implementation in Python 3.13.0b1 uses time.time_ns() instead +of time.time(). +--- + tests/unit/test_base_command.py | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/tests/unit/test_base_command.py b/tests/unit/test_base_command.py +index 80c93799d94..f9fae651422 100644 +--- a/tests/unit/test_base_command.py ++++ b/tests/unit/test_base_command.py +@@ -17,8 +17,12 @@ + + @pytest.fixture + def fixed_time() -> Iterator[None]: +- with patch("time.time", lambda: 1547704837.040001 + time.timezone): +- yield ++ # Patch time so logs contain a constant timestamp. time.time_ns is used by ++ # logging starting with Python 3.13. ++ year2019 = 1547704837.040001 + time.timezone ++ with patch("time.time", lambda: year2019): ++ with patch("time.time_ns", lambda: int(year2019 * 1e9)): ++ yield + + + class FakeCommand(Command): diff --git a/python-pip.spec b/python-pip.spec index 13f8830..5969cd0 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -82,6 +82,9 @@ Patch: nowarn-pip._internal.main.patch # Upstream issue: https://github.com/pypa/packaging/issues/368 Patch: no-version-warning.patch +# Python 3.13 support: Also patch time.time_ns() in unit tests +Patch: https://github.com/pypa/pip/pull/12698.patch + %description pip is a package management system used to install and manage software packages written in Python. Many packages can be found in the Python Package Index