File 12698.patch of Package python-pip

From a2b23ffd477dcd90de6f1cb1f4cb75e0229d0e16 Mon Sep 17 00:00:00 2001
From: Richard Si <sichard26@gmail.com>
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):
openSUSE Build Service is sponsored by