From 7eebd11a28b557b20d8a336c46b26c7cd6294bc0 Mon Sep 17 00:00:00 2001 From: Reilly Brogan Date: Thu, 25 Apr 2024 14:48:23 -0500 Subject: [PATCH 1/2] Fixed test_empty_NO_COLOR_and_FORCE_COLOR_ignored when TERM=dumb Dumb terminals are incapable of handling color, so this test would fail when ran in such an environment --- AUTHORS | 1 + changelog/12244.bugfix.rst | 1 + testing/io/test_terminalwriter.py | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/12244.bugfix.rst diff --git a/AUTHORS b/AUTHORS index d7148acfc..5d8c7f5f3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -339,6 +339,7 @@ Rafal Semik Raquel Alegre Ravi Chandra Reagan Lee +Reilly Brogan Robert Holt Roberto Aldera Roberto Polli diff --git a/changelog/12244.bugfix.rst b/changelog/12244.bugfix.rst new file mode 100644 index 000000000..b348f35e8 --- /dev/null +++ b/changelog/12244.bugfix.rst @@ -0,0 +1 @@ +Fixed a test failure with `test_empty_NO_COLOR_and_FORCE_COLOR_ignored` when `TERM=dumb` diff --git a/testing/io/test_terminalwriter.py b/testing/io/test_terminalwriter.py index afa8d5cae..d4b4786dd 100644 --- a/testing/io/test_terminalwriter.py +++ b/testing/io/test_terminalwriter.py @@ -221,7 +221,10 @@ def test_NO_COLOR_and_FORCE_COLOR( monkeypatch.setitem(os.environ, "FORCE_COLOR", FORCE_COLOR) assert_color(expected) - +@pytest.mark.skipif( + os.environ["TERM"] == "dumb" or "NO_COLOR" in os.environ, + reason="dumb terminals can't handle color" + ) def test_empty_NO_COLOR_and_FORCE_COLOR_ignored(monkeypatch: MonkeyPatch) -> None: monkeypatch.setitem(os.environ, "NO_COLOR", "") monkeypatch.setitem(os.environ, "FORCE_COLOR", "") From f380419a513175636f286edc994f0f5100e27d72 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:05:32 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/io/test_terminalwriter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/io/test_terminalwriter.py b/testing/io/test_terminalwriter.py index d4b4786dd..9f85cee94 100644 --- a/testing/io/test_terminalwriter.py +++ b/testing/io/test_terminalwriter.py @@ -221,10 +221,11 @@ def test_NO_COLOR_and_FORCE_COLOR( monkeypatch.setitem(os.environ, "FORCE_COLOR", FORCE_COLOR) assert_color(expected) + @pytest.mark.skipif( os.environ["TERM"] == "dumb" or "NO_COLOR" in os.environ, - reason="dumb terminals can't handle color" - ) + reason="dumb terminals can't handle color", +) def test_empty_NO_COLOR_and_FORCE_COLOR_ignored(monkeypatch: MonkeyPatch) -> None: monkeypatch.setitem(os.environ, "NO_COLOR", "") monkeypatch.setitem(os.environ, "FORCE_COLOR", "")