From 4ed68c6d1e9e79d85925fb1e19e348c8864b6ffb Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Mon, 3 Aug 2026 18:57:57 +0200 Subject: [PATCH] test(framework): silence expected gh_issue error logs The gh_issue unit tests deliberately drive error paths, and the resulting ERROR records were printed by pytest live logging. Raise the gh_issue logger level to CRITICAL via a quiet_logger fixture in the tests that expect errors, keeping the test output clean. --- framework_tests/test_gh_issue.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/framework_tests/test_gh_issue.py b/framework_tests/test_gh_issue.py index 2112a5662..22ffbf130 100644 --- a/framework_tests/test_gh_issue.py +++ b/framework_tests/test_gh_issue.py @@ -4,6 +4,7 @@ monkeypatched with a fake that returns canned issue states. """ +import logging import types import typing as tp @@ -37,6 +38,12 @@ def clean_cache(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(gh_issue.GHIssue, "issue_cache", {}) +@pytest.fixture +def quiet_logger(caplog: pytest.LogCaptureFixture) -> None: + """Silence expected error logs from the `gh_issue` module.""" + caplog.set_level(logging.CRITICAL, logger=gh_issue.LOGGER.name) + + def _set_github(monkeypatch: pytest.MonkeyPatch, fake: _FakeGithub | None) -> None: """Make `GHIssue` use the given fake GitHub instance.""" monkeypatch.setattr(gh_issue.GHIssue, "_get_github", classmethod(lambda _cls: fake)) @@ -55,6 +62,7 @@ def test_state_cached(self, monkeypatch: pytest.MonkeyPatch): assert issue.get_state() == gh_issue.STATE_CLOSED assert fake.calls == 1 + @pytest.mark.usefixtures("quiet_logger") def test_unknown_issue_cached(self, monkeypatch: pytest.MonkeyPatch): """Cache the state of a nonexistent issue, it cannot appear later.""" fake = _FakeGithub(responses=[github.UnknownObjectException(status=404)]) @@ -64,6 +72,7 @@ def test_unknown_issue_cached(self, monkeypatch: pytest.MonkeyPatch): assert issue.get_state() == gh_issue.STATE_UNKNOWN assert fake.calls == 1 + @pytest.mark.usefixtures("quiet_logger") def test_transient_failure_not_cached(self, monkeypatch: pytest.MonkeyPatch): """Don't cache a failed state retrieval, the next call may succeed.""" fake = _FakeGithub(responses=[RuntimeError("API is down"), "OPEN"]) @@ -74,6 +83,7 @@ def test_transient_failure_not_cached(self, monkeypatch: pytest.MonkeyPatch): assert issue.get_state() == "open" assert fake.calls == 2 + @pytest.mark.usefixtures("quiet_logger") def test_no_github_instance(self, monkeypatch: pytest.MonkeyPatch): """Report a state retrieval failure when the GitHub instance is not available.""" _set_github(monkeypatch, None)