public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-python/time-machine/, dev-python/time-machine/files/
@ 2023-11-14  1:35 Sam James
  0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2023-11-14  1:35 UTC (permalink / raw
  To: gentoo-commits

commit:     2b25ffa64a4f780e8f1c0d75d0ae5e27f245efb8
Author:     Matoro Mahri <matoro_gentoo <AT> matoro <DOT> tk>
AuthorDate: Sun Nov 12 17:26:36 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Nov 14 01:35:06 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2b25ffa6

dev-python/time-machine: fix tests on low clock resolution

See: https://github.com/adamchainz/time-machine/pull/400
Closes: https://bugs.gentoo.org/912709
Bug: https://bugs.gentoo.org/910367
Signed-off-by: Matoro Mahri <matoro_gentoo <AT> matoro.tk>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/time-machine-2.13.0-backport-pr400.patch | 252 +++++++++++++++++++++
 dev-python/time-machine/time-machine-2.13.0.ebuild |   2 +
 2 files changed, 254 insertions(+)

diff --git a/dev-python/time-machine/files/time-machine-2.13.0-backport-pr400.patch b/dev-python/time-machine/files/time-machine-2.13.0-backport-pr400.patch
new file mode 100644
index 000000000000..b7fa55c2e267
--- /dev/null
+++ b/dev-python/time-machine/files/time-machine-2.13.0-backport-pr400.patch
@@ -0,0 +1,252 @@
+https://bugs.gentoo.org/show_bug.cgi?id=912709
+https://github.com/adamchainz/time-machine/pull/400
+
+From b489a478193982c17cf7847d32cae2b53a904222 Mon Sep 17 00:00:00 2001
+From: matoro <matoro@users.noreply.github.com>
+Date: Thu, 9 Nov 2023 13:03:49 -0500
+Subject: [PATCH 1/2] Fix tests on platforms with low clock resolution
+
+On platforms without a high-resolution clock, such as Alpha and PA-RISC
+is is likely that two sequential calls to time.time() will return the
+same value if the execution time is not sufficient to allow one full
+clock resolution cycle to pass.  This adds sleeps of one cycle to
+enforce that the minimum amount of time to guarantee a clock change has
+passed.
+
+On systems with high-resolution clocks, clock_getres() will return 1ns;
+in reality the sleep will take longer than 1ns to execute but should
+still be a negligible amount of time.
+---
+ tests/test_time_machine.py | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/tests/test_time_machine.py b/tests/test_time_machine.py
+index fe98fb7..7b5abbe 100644
+--- a/tests/test_time_machine.py
++++ b/tests/test_time_machine.py
+@@ -155,8 +155,10 @@ def test_time_clock_gettime_realtime():
+ @py_have_clock_gettime
+ def test_time_clock_gettime_monotonic_unaffected():
+     start = time.clock_gettime(time.CLOCK_MONOTONIC)
++    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+     with time_machine.travel(EPOCH + 180.0):
+         frozen = time.clock_gettime(time.CLOCK_MONOTONIC)
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert isinstance(frozen, float)
+         assert frozen > start
+ 
+@@ -169,6 +171,7 @@ def test_time_clock_gettime_monotonic_unaffected():
+ def test_time_clock_gettime_ns_realtime():
+     with time_machine.travel(EPOCH + 190.0):
+         first = time.clock_gettime_ns(time.CLOCK_REALTIME)
++        time.sleep(time.clock_getres(time.CLOCK_REALTIME))
+         assert isinstance(first, int)
+         assert first == int((EPOCH + 190.0) * NANOSECONDS_PER_SECOND)
+         second = time.clock_gettime_ns(time.CLOCK_REALTIME)
+@@ -182,8 +185,10 @@ def test_time_clock_gettime_ns_realtime():
+ @py_have_clock_gettime
+ def test_time_clock_gettime_ns_monotonic_unaffected():
+     start = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
++    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+     with time_machine.travel(EPOCH + 190.0):
+         frozen = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert isinstance(frozen, int)
+         assert frozen > start
+ 
+@@ -279,6 +284,7 @@ def test_time_strftime_format_t():
+ def test_time_time():
+     with time_machine.travel(EPOCH):
+         first = time.time()
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert isinstance(first, float)
+         assert first == EPOCH
+         second = time.time()
+@@ -300,6 +306,7 @@ def test_time_time():
+ def test_time_time_windows():
+     with time_machine.travel(EPOCH):
+         first = time.time()
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert isinstance(first, float)
+         assert first == windows_epoch_in_posix
+ 
+@@ -316,6 +323,7 @@ def test_time_time_no_tick():
+ def test_time_time_ns():
+     with time_machine.travel(EPOCH + 150.0):
+         first = time.time_ns()
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert isinstance(first, int)
+         assert first == int((EPOCH + 150.0) * NANOSECONDS_PER_SECOND)
+         second = time.time_ns()
+@@ -561,6 +569,7 @@ def test_method_decorator(self):
+ @time_machine.travel(EPOCH + 95.0)
+ class UnitTestClassTests(TestCase):
+     def test_class_decorator(self):
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert EPOCH + 95.0 < time.time() < EPOCH + 96.0
+ 
+     @time_machine.travel(EPOCH + 25.0)
+@@ -578,6 +587,7 @@ def setUpClass(cls):
+         cls.custom_setupclass_ran = True
+ 
+     def test_class_decorator(self):
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert EPOCH + 95.0 < time.time() < EPOCH + 96.0
+         assert self.custom_setupclass_ran
+ 
+@@ -639,6 +649,7 @@ def test_move_to_datetime():
+         traveller.move_to(EPOCH_PLUS_ONE_YEAR_DATETIME)
+ 
+         first = time.time()
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert first == EPOCH_PLUS_ONE_YEAR
+ 
+         second = time.time()
+@@ -706,6 +717,7 @@ def test_move_to_datetime_change_tick_on():
+     with time_machine.travel(EPOCH, tick=False) as traveller:
+         traveller.move_to(EPOCH_PLUS_ONE_YEAR_DATETIME, tick=True)
+         assert time.time() == EPOCH_PLUS_ONE_YEAR
++        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+         assert time.time() > EPOCH_PLUS_ONE_YEAR
+ 
+ 
+@@ -756,6 +768,7 @@ def test_fixture_used_tick_false(time_machine):
+ def test_fixture_used_tick_true(time_machine):
+     time_machine.move_to(EPOCH, tick=True)
+     original = time.time()
++    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
+     assert original == EPOCH
+     assert original < time.time() < EPOCH + 10.0
+ 
+
+From 9e84584325ec06eb997716b6a0f42e9ca6540994 Mon Sep 17 00:00:00 2001
+From: matoro <matoro@users.noreply.github.com>
+Date: Fri, 10 Nov 2023 11:06:23 -0500
+Subject: [PATCH 2/2] Wrap sleep calls in "sleep_one_cycle" function
+
+---
+ tests/test_time_machine.py | 30 +++++++++++++++++-------------
+ 1 file changed, 17 insertions(+), 13 deletions(-)
+
+diff --git a/tests/test_time_machine.py b/tests/test_time_machine.py
+index 7b5abbe..163ec2b 100644
+--- a/tests/test_time_machine.py
++++ b/tests/test_time_machine.py
+@@ -38,6 +38,10 @@
+ )
+ 
+ 
++def sleep_one_cycle(clock: int) -> None:
++    time.sleep(time.clock_getres(clock))
++
++
+ @contextmanager
+ def change_local_timezone(local_tz: str | None) -> typing.Iterator[None]:
+     orig_tz = os.environ["TZ"]
+@@ -155,10 +159,10 @@ def test_time_clock_gettime_realtime():
+ @py_have_clock_gettime
+ def test_time_clock_gettime_monotonic_unaffected():
+     start = time.clock_gettime(time.CLOCK_MONOTONIC)
+-    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++    sleep_one_cycle(time.CLOCK_MONOTONIC)
+     with time_machine.travel(EPOCH + 180.0):
+         frozen = time.clock_gettime(time.CLOCK_MONOTONIC)
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert isinstance(frozen, float)
+         assert frozen > start
+ 
+@@ -171,7 +175,7 @@ def test_time_clock_gettime_monotonic_unaffected():
+ def test_time_clock_gettime_ns_realtime():
+     with time_machine.travel(EPOCH + 190.0):
+         first = time.clock_gettime_ns(time.CLOCK_REALTIME)
+-        time.sleep(time.clock_getres(time.CLOCK_REALTIME))
++        sleep_one_cycle(time.CLOCK_REALTIME)
+         assert isinstance(first, int)
+         assert first == int((EPOCH + 190.0) * NANOSECONDS_PER_SECOND)
+         second = time.clock_gettime_ns(time.CLOCK_REALTIME)
+@@ -185,10 +189,10 @@ def test_time_clock_gettime_ns_realtime():
+ @py_have_clock_gettime
+ def test_time_clock_gettime_ns_monotonic_unaffected():
+     start = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
+-    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++    sleep_one_cycle(time.CLOCK_MONOTONIC)
+     with time_machine.travel(EPOCH + 190.0):
+         frozen = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert isinstance(frozen, int)
+         assert frozen > start
+ 
+@@ -284,7 +288,7 @@ def test_time_strftime_format_t():
+ def test_time_time():
+     with time_machine.travel(EPOCH):
+         first = time.time()
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert isinstance(first, float)
+         assert first == EPOCH
+         second = time.time()
+@@ -306,7 +310,7 @@ def test_time_time():
+ def test_time_time_windows():
+     with time_machine.travel(EPOCH):
+         first = time.time()
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert isinstance(first, float)
+         assert first == windows_epoch_in_posix
+ 
+@@ -323,7 +327,7 @@ def test_time_time_no_tick():
+ def test_time_time_ns():
+     with time_machine.travel(EPOCH + 150.0):
+         first = time.time_ns()
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert isinstance(first, int)
+         assert first == int((EPOCH + 150.0) * NANOSECONDS_PER_SECOND)
+         second = time.time_ns()
+@@ -569,7 +573,7 @@ def test_method_decorator(self):
+ @time_machine.travel(EPOCH + 95.0)
+ class UnitTestClassTests(TestCase):
+     def test_class_decorator(self):
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert EPOCH + 95.0 < time.time() < EPOCH + 96.0
+ 
+     @time_machine.travel(EPOCH + 25.0)
+@@ -587,7 +591,7 @@ def setUpClass(cls):
+         cls.custom_setupclass_ran = True
+ 
+     def test_class_decorator(self):
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert EPOCH + 95.0 < time.time() < EPOCH + 96.0
+         assert self.custom_setupclass_ran
+ 
+@@ -649,7 +653,7 @@ def test_move_to_datetime():
+         traveller.move_to(EPOCH_PLUS_ONE_YEAR_DATETIME)
+ 
+         first = time.time()
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert first == EPOCH_PLUS_ONE_YEAR
+ 
+         second = time.time()
+@@ -717,7 +721,7 @@ def test_move_to_datetime_change_tick_on():
+     with time_machine.travel(EPOCH, tick=False) as traveller:
+         traveller.move_to(EPOCH_PLUS_ONE_YEAR_DATETIME, tick=True)
+         assert time.time() == EPOCH_PLUS_ONE_YEAR
+-        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++        sleep_one_cycle(time.CLOCK_MONOTONIC)
+         assert time.time() > EPOCH_PLUS_ONE_YEAR
+ 
+ 
+@@ -768,7 +772,7 @@ def test_fixture_used_tick_false(time_machine):
+ def test_fixture_used_tick_true(time_machine):
+     time_machine.move_to(EPOCH, tick=True)
+     original = time.time()
+-    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
++    sleep_one_cycle(time.CLOCK_MONOTONIC)
+     assert original == EPOCH
+     assert original < time.time() < EPOCH + 10.0
+ 

diff --git a/dev-python/time-machine/time-machine-2.13.0.ebuild b/dev-python/time-machine/time-machine-2.13.0.ebuild
index b759fd9cf9d8..6b03b3926bee 100644
--- a/dev-python/time-machine/time-machine-2.13.0.ebuild
+++ b/dev-python/time-machine/time-machine-2.13.0.ebuild
@@ -27,4 +27,6 @@ RDEPEND="
 	dev-python/python-dateutil[${PYTHON_USEDEP}]
 "
 
+PATCHES=( "${FILESDIR}/${PN}-2.13.0-backport-pr400.patch" )
+
 distutils_enable_tests pytest


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/time-machine/, dev-python/time-machine/files/
@ 2024-04-29  3:27 Michał Górny
  0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2024-04-29  3:27 UTC (permalink / raw
  To: gentoo-commits

commit:     ff77218995e7991575d11b08b65a2fdfd6d2003e
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 29 02:27:16 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Apr 29 03:27:29 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ff772189

dev-python/time-machine: Remove old

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/time-machine/Manifest                   |   2 -
 .../files/time-machine-2.13.0-backport-pr400.patch | 252 ---------------------
 dev-python/time-machine/time-machine-2.13.0.ebuild |  32 ---
 dev-python/time-machine/time-machine-2.14.0.ebuild |  30 ---
 4 files changed, 316 deletions(-)

diff --git a/dev-python/time-machine/Manifest b/dev-python/time-machine/Manifest
index c04e351318ca..8c94468934a9 100644
--- a/dev-python/time-machine/Manifest
+++ b/dev-python/time-machine/Manifest
@@ -1,3 +1 @@
-DIST time-machine-2.13.0.gh.tar.gz 28747 BLAKE2B 88836d2b9ad34c8d256b576ab6b2bfe263232fb50d2e95f13049f84dbc838283811ebc54c5bb68493ef966e64777983ab6bcb7fafccda6dc74e00d3bb6a2108f SHA512 26a852d93633e037585ec8fcd563c86af8d977a87633dbeb66cf23c9ca49ca0ae536bdcdcdf809ee2ab423c197610c630d506bc3bf4f13c373d806cee2d8c598
-DIST time-machine-2.14.0.gh.tar.gz 29270 BLAKE2B 55050879fe221204f14c77a90190c2ef5232e182d281885d60686230365b9249f8e90ec80e7a842d43a2c52b72bf463cd59b4a22fdc8b0cd25c5ad5b0306fc98 SHA512 7bc9d6d53da68c18ccdae1af6282ea482a0758a4fda9acabe9fa39bfe217a57e65b8041ae4436b7cef2c0b39835f3aae9590515d200b9b2962bd0610370e8454
 DIST time-machine-2.14.1.gh.tar.gz 29600 BLAKE2B b118e3a2f08f75cc6cd89181a9e533c89bc6e5312a520b2a854fb8aa7ac59f1570e48a85788261f781ef83f9864380318074724f6eadab9cda7a3374b2322e7d SHA512 42a127e2dc5a86e33896010e6d141fc9248fe685d3477ec71ec8a72315914cea99ae4a4d6623a59fd69505d935d2feadcfd831a7fff5617c3f98a93d48652ecf

diff --git a/dev-python/time-machine/files/time-machine-2.13.0-backport-pr400.patch b/dev-python/time-machine/files/time-machine-2.13.0-backport-pr400.patch
deleted file mode 100644
index b7fa55c2e267..000000000000
--- a/dev-python/time-machine/files/time-machine-2.13.0-backport-pr400.patch
+++ /dev/null
@@ -1,252 +0,0 @@
-https://bugs.gentoo.org/show_bug.cgi?id=912709
-https://github.com/adamchainz/time-machine/pull/400
-
-From b489a478193982c17cf7847d32cae2b53a904222 Mon Sep 17 00:00:00 2001
-From: matoro <matoro@users.noreply.github.com>
-Date: Thu, 9 Nov 2023 13:03:49 -0500
-Subject: [PATCH 1/2] Fix tests on platforms with low clock resolution
-
-On platforms without a high-resolution clock, such as Alpha and PA-RISC
-is is likely that two sequential calls to time.time() will return the
-same value if the execution time is not sufficient to allow one full
-clock resolution cycle to pass.  This adds sleeps of one cycle to
-enforce that the minimum amount of time to guarantee a clock change has
-passed.
-
-On systems with high-resolution clocks, clock_getres() will return 1ns;
-in reality the sleep will take longer than 1ns to execute but should
-still be a negligible amount of time.
----
- tests/test_time_machine.py | 13 +++++++++++++
- 1 file changed, 13 insertions(+)
-
-diff --git a/tests/test_time_machine.py b/tests/test_time_machine.py
-index fe98fb7..7b5abbe 100644
---- a/tests/test_time_machine.py
-+++ b/tests/test_time_machine.py
-@@ -155,8 +155,10 @@ def test_time_clock_gettime_realtime():
- @py_have_clock_gettime
- def test_time_clock_gettime_monotonic_unaffected():
-     start = time.clock_gettime(time.CLOCK_MONOTONIC)
-+    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-     with time_machine.travel(EPOCH + 180.0):
-         frozen = time.clock_gettime(time.CLOCK_MONOTONIC)
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert isinstance(frozen, float)
-         assert frozen > start
- 
-@@ -169,6 +171,7 @@ def test_time_clock_gettime_monotonic_unaffected():
- def test_time_clock_gettime_ns_realtime():
-     with time_machine.travel(EPOCH + 190.0):
-         first = time.clock_gettime_ns(time.CLOCK_REALTIME)
-+        time.sleep(time.clock_getres(time.CLOCK_REALTIME))
-         assert isinstance(first, int)
-         assert first == int((EPOCH + 190.0) * NANOSECONDS_PER_SECOND)
-         second = time.clock_gettime_ns(time.CLOCK_REALTIME)
-@@ -182,8 +185,10 @@ def test_time_clock_gettime_ns_realtime():
- @py_have_clock_gettime
- def test_time_clock_gettime_ns_monotonic_unaffected():
-     start = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
-+    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-     with time_machine.travel(EPOCH + 190.0):
-         frozen = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert isinstance(frozen, int)
-         assert frozen > start
- 
-@@ -279,6 +284,7 @@ def test_time_strftime_format_t():
- def test_time_time():
-     with time_machine.travel(EPOCH):
-         first = time.time()
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert isinstance(first, float)
-         assert first == EPOCH
-         second = time.time()
-@@ -300,6 +306,7 @@ def test_time_time():
- def test_time_time_windows():
-     with time_machine.travel(EPOCH):
-         first = time.time()
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert isinstance(first, float)
-         assert first == windows_epoch_in_posix
- 
-@@ -316,6 +323,7 @@ def test_time_time_no_tick():
- def test_time_time_ns():
-     with time_machine.travel(EPOCH + 150.0):
-         first = time.time_ns()
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert isinstance(first, int)
-         assert first == int((EPOCH + 150.0) * NANOSECONDS_PER_SECOND)
-         second = time.time_ns()
-@@ -561,6 +569,7 @@ def test_method_decorator(self):
- @time_machine.travel(EPOCH + 95.0)
- class UnitTestClassTests(TestCase):
-     def test_class_decorator(self):
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert EPOCH + 95.0 < time.time() < EPOCH + 96.0
- 
-     @time_machine.travel(EPOCH + 25.0)
-@@ -578,6 +587,7 @@ def setUpClass(cls):
-         cls.custom_setupclass_ran = True
- 
-     def test_class_decorator(self):
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert EPOCH + 95.0 < time.time() < EPOCH + 96.0
-         assert self.custom_setupclass_ran
- 
-@@ -639,6 +649,7 @@ def test_move_to_datetime():
-         traveller.move_to(EPOCH_PLUS_ONE_YEAR_DATETIME)
- 
-         first = time.time()
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert first == EPOCH_PLUS_ONE_YEAR
- 
-         second = time.time()
-@@ -706,6 +717,7 @@ def test_move_to_datetime_change_tick_on():
-     with time_machine.travel(EPOCH, tick=False) as traveller:
-         traveller.move_to(EPOCH_PLUS_ONE_YEAR_DATETIME, tick=True)
-         assert time.time() == EPOCH_PLUS_ONE_YEAR
-+        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-         assert time.time() > EPOCH_PLUS_ONE_YEAR
- 
- 
-@@ -756,6 +768,7 @@ def test_fixture_used_tick_false(time_machine):
- def test_fixture_used_tick_true(time_machine):
-     time_machine.move_to(EPOCH, tick=True)
-     original = time.time()
-+    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-     assert original == EPOCH
-     assert original < time.time() < EPOCH + 10.0
- 
-
-From 9e84584325ec06eb997716b6a0f42e9ca6540994 Mon Sep 17 00:00:00 2001
-From: matoro <matoro@users.noreply.github.com>
-Date: Fri, 10 Nov 2023 11:06:23 -0500
-Subject: [PATCH 2/2] Wrap sleep calls in "sleep_one_cycle" function
-
----
- tests/test_time_machine.py | 30 +++++++++++++++++-------------
- 1 file changed, 17 insertions(+), 13 deletions(-)
-
-diff --git a/tests/test_time_machine.py b/tests/test_time_machine.py
-index 7b5abbe..163ec2b 100644
---- a/tests/test_time_machine.py
-+++ b/tests/test_time_machine.py
-@@ -38,6 +38,10 @@
- )
- 
- 
-+def sleep_one_cycle(clock: int) -> None:
-+    time.sleep(time.clock_getres(clock))
-+
-+
- @contextmanager
- def change_local_timezone(local_tz: str | None) -> typing.Iterator[None]:
-     orig_tz = os.environ["TZ"]
-@@ -155,10 +159,10 @@ def test_time_clock_gettime_realtime():
- @py_have_clock_gettime
- def test_time_clock_gettime_monotonic_unaffected():
-     start = time.clock_gettime(time.CLOCK_MONOTONIC)
--    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+    sleep_one_cycle(time.CLOCK_MONOTONIC)
-     with time_machine.travel(EPOCH + 180.0):
-         frozen = time.clock_gettime(time.CLOCK_MONOTONIC)
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert isinstance(frozen, float)
-         assert frozen > start
- 
-@@ -171,7 +175,7 @@ def test_time_clock_gettime_monotonic_unaffected():
- def test_time_clock_gettime_ns_realtime():
-     with time_machine.travel(EPOCH + 190.0):
-         first = time.clock_gettime_ns(time.CLOCK_REALTIME)
--        time.sleep(time.clock_getres(time.CLOCK_REALTIME))
-+        sleep_one_cycle(time.CLOCK_REALTIME)
-         assert isinstance(first, int)
-         assert first == int((EPOCH + 190.0) * NANOSECONDS_PER_SECOND)
-         second = time.clock_gettime_ns(time.CLOCK_REALTIME)
-@@ -185,10 +189,10 @@ def test_time_clock_gettime_ns_realtime():
- @py_have_clock_gettime
- def test_time_clock_gettime_ns_monotonic_unaffected():
-     start = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
--    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+    sleep_one_cycle(time.CLOCK_MONOTONIC)
-     with time_machine.travel(EPOCH + 190.0):
-         frozen = time.clock_gettime_ns(time.CLOCK_MONOTONIC)
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert isinstance(frozen, int)
-         assert frozen > start
- 
-@@ -284,7 +288,7 @@ def test_time_strftime_format_t():
- def test_time_time():
-     with time_machine.travel(EPOCH):
-         first = time.time()
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert isinstance(first, float)
-         assert first == EPOCH
-         second = time.time()
-@@ -306,7 +310,7 @@ def test_time_time():
- def test_time_time_windows():
-     with time_machine.travel(EPOCH):
-         first = time.time()
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert isinstance(first, float)
-         assert first == windows_epoch_in_posix
- 
-@@ -323,7 +327,7 @@ def test_time_time_no_tick():
- def test_time_time_ns():
-     with time_machine.travel(EPOCH + 150.0):
-         first = time.time_ns()
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert isinstance(first, int)
-         assert first == int((EPOCH + 150.0) * NANOSECONDS_PER_SECOND)
-         second = time.time_ns()
-@@ -569,7 +573,7 @@ def test_method_decorator(self):
- @time_machine.travel(EPOCH + 95.0)
- class UnitTestClassTests(TestCase):
-     def test_class_decorator(self):
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert EPOCH + 95.0 < time.time() < EPOCH + 96.0
- 
-     @time_machine.travel(EPOCH + 25.0)
-@@ -587,7 +591,7 @@ def setUpClass(cls):
-         cls.custom_setupclass_ran = True
- 
-     def test_class_decorator(self):
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert EPOCH + 95.0 < time.time() < EPOCH + 96.0
-         assert self.custom_setupclass_ran
- 
-@@ -649,7 +653,7 @@ def test_move_to_datetime():
-         traveller.move_to(EPOCH_PLUS_ONE_YEAR_DATETIME)
- 
-         first = time.time()
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert first == EPOCH_PLUS_ONE_YEAR
- 
-         second = time.time()
-@@ -717,7 +721,7 @@ def test_move_to_datetime_change_tick_on():
-     with time_machine.travel(EPOCH, tick=False) as traveller:
-         traveller.move_to(EPOCH_PLUS_ONE_YEAR_DATETIME, tick=True)
-         assert time.time() == EPOCH_PLUS_ONE_YEAR
--        time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+        sleep_one_cycle(time.CLOCK_MONOTONIC)
-         assert time.time() > EPOCH_PLUS_ONE_YEAR
- 
- 
-@@ -768,7 +772,7 @@ def test_fixture_used_tick_false(time_machine):
- def test_fixture_used_tick_true(time_machine):
-     time_machine.move_to(EPOCH, tick=True)
-     original = time.time()
--    time.sleep(time.clock_getres(time.CLOCK_MONOTONIC))
-+    sleep_one_cycle(time.CLOCK_MONOTONIC)
-     assert original == EPOCH
-     assert original < time.time() < EPOCH + 10.0
- 

diff --git a/dev-python/time-machine/time-machine-2.13.0.ebuild b/dev-python/time-machine/time-machine-2.13.0.ebuild
deleted file mode 100644
index 040dc0489bc5..000000000000
--- a/dev-python/time-machine/time-machine-2.13.0.ebuild
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2022-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-DISTUTILS_EXT=1
-DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{10..12} )
-
-inherit distutils-r1
-
-DESCRIPTION="Travel through time in your tests"
-HOMEPAGE="
-	https://github.com/adamchainz/time-machine/
-	https://pypi.org/project/time-machine/
-"
-SRC_URI="
-	https://github.com/adamchainz/time-machine/archive/${PV}.tar.gz
-		-> ${P}.gh.tar.gz
-"
-
-LICENSE="MIT"
-SLOT="0"
-KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
-
-RDEPEND="
-	dev-python/python-dateutil[${PYTHON_USEDEP}]
-"
-
-PATCHES=( "${FILESDIR}/${PN}-2.13.0-backport-pr400.patch" )
-
-distutils_enable_tests pytest

diff --git a/dev-python/time-machine/time-machine-2.14.0.ebuild b/dev-python/time-machine/time-machine-2.14.0.ebuild
deleted file mode 100644
index 462fe2809ad3..000000000000
--- a/dev-python/time-machine/time-machine-2.14.0.ebuild
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2022-2024 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-DISTUTILS_EXT=1
-DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{10..12} )
-
-inherit distutils-r1
-
-DESCRIPTION="Travel through time in your tests"
-HOMEPAGE="
-	https://github.com/adamchainz/time-machine/
-	https://pypi.org/project/time-machine/
-"
-SRC_URI="
-	https://github.com/adamchainz/time-machine/archive/${PV}.tar.gz
-		-> ${P}.gh.tar.gz
-"
-
-LICENSE="MIT"
-SLOT="0"
-KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
-
-RDEPEND="
-	dev-python/python-dateutil[${PYTHON_USEDEP}]
-"
-
-distutils_enable_tests pytest


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-29  3:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-14  1:35 [gentoo-commits] repo/gentoo:master commit in: dev-python/time-machine/, dev-python/time-machine/files/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2024-04-29  3:27 Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox