From 03dbb782638efaab42eb2bb12f2aed91b37e95ac Mon Sep 17 00:00:00 2001 From: James Addison Date: Fri, 9 May 2025 13:01:47 +0100 Subject: [PATCH 1/3] Tests: linkcheck: ensure Python clock timezone is reset during test teardown --- tests/test_builders/test_build_linkcheck.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_builders/test_build_linkcheck.py b/tests/test_builders/test_build_linkcheck.py index bdd8dea54c1..34e4bf6d64c 100644 --- a/tests/test_builders/test_build_linkcheck.py +++ b/tests/test_builders/test_build_linkcheck.py @@ -1144,6 +1144,9 @@ def test_too_many_requests_retry_after_HTTP_date(tz, app, monkeypatch, capsys): """, ) + if sys.platform != 'win32': + time.tzset() + @pytest.mark.sphinx( 'linkcheck', From 8923bb0f0234cee51757d9e93c0d6efaf66b1c22 Mon Sep 17 00:00:00 2001 From: James Addison Date: Fri, 9 May 2025 13:11:08 +0100 Subject: [PATCH 2/3] Tests: linkcheck: add explanatory comment Relates-to commit 03dbb782638efaab42eb2bb12f2aed91b37e95ac. --- tests/test_builders/test_build_linkcheck.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_builders/test_build_linkcheck.py b/tests/test_builders/test_build_linkcheck.py index 34e4bf6d64c..685147c81a2 100644 --- a/tests/test_builders/test_build_linkcheck.py +++ b/tests/test_builders/test_build_linkcheck.py @@ -1144,6 +1144,8 @@ def test_too_many_requests_retry_after_HTTP_date(tz, app, monkeypatch, capsys): """, ) + # Teardown: the monkeypatch context manager clears the TZ environment variable, but + # we also need to reset Python's internal notion of the current timezone. if sys.platform != 'win32': time.tzset() From 774e464eeadd2792019d8b6d17332687619244fa Mon Sep 17 00:00:00 2001 From: James Addison Date: Mon, 12 May 2025 17:55:55 +0100 Subject: [PATCH 3/3] Tests: linkcheck: relocate clock-reset operation --- tests/test_builders/test_build_linkcheck.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_builders/test_build_linkcheck.py b/tests/test_builders/test_build_linkcheck.py index 685147c81a2..b0c74856b4e 100644 --- a/tests/test_builders/test_build_linkcheck.py +++ b/tests/test_builders/test_build_linkcheck.py @@ -1127,6 +1127,12 @@ def test_too_many_requests_retry_after_HTTP_date(tz, app, monkeypatch, capsys): ) as address: app.build() + # Undo side-effects: the monkeypatch context manager clears the TZ environment + # variable, but we also need to reset Python's internal notion of the current + # timezone. + if sys.platform != 'win32': + time.tzset() + content = (app.outdir / 'output.json').read_text(encoding='utf8') assert json.loads(content) == { 'filename': 'index.rst', @@ -1144,11 +1150,6 @@ def test_too_many_requests_retry_after_HTTP_date(tz, app, monkeypatch, capsys): """, ) - # Teardown: the monkeypatch context manager clears the TZ environment variable, but - # we also need to reset Python's internal notion of the current timezone. - if sys.platform != 'win32': - time.tzset() - @pytest.mark.sphinx( 'linkcheck',