From bb4d7abd27e3a9dbe56261137227978c05ab2cb0 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 28 Dec 2021 14:09:58 +0000 Subject: [PATCH 1/2] Fix local test failure to do with FORCE_COLOR --- tests/test_main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 17d171af..654fe6eb 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -602,7 +602,8 @@ def test_main_noxfile_options_with_sessions_override( @pytest.mark.parametrize(("isatty_value", "expected"), [(True, True), (False, False)]) def test_main_color_from_isatty(monkeypatch, isatty_value, expected): - monkeypatch.delenv("FORCE_COLOR") + if os.getenv("FORCE_COLOR"): + monkeypatch.delenv("FORCE_COLOR") monkeypatch.setattr(sys, "argv", [sys.executable]) with mock.patch("nox.workflow.execute") as execute: execute.return_value = 0 @@ -627,7 +628,8 @@ def test_main_color_from_isatty(monkeypatch, isatty_value, expected): ], ) def test_main_color_options(monkeypatch, color_opt, expected): - monkeypatch.delenv("FORCE_COLOR") + if os.getenv("FORCE_COLOR"): + monkeypatch.delenv("FORCE_COLOR") monkeypatch.setattr(sys, "argv", [sys.executable, color_opt]) with mock.patch("nox.workflow.execute") as execute: execute.return_value = 0 From 00c436350b70d416637f784b4bbf08ca9f1bc9b0 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 28 Dec 2021 14:27:28 +0000 Subject: [PATCH 2/2] Simplify monkeypatch check --- tests/test_main.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 654fe6eb..9cf65b38 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -602,8 +602,7 @@ def test_main_noxfile_options_with_sessions_override( @pytest.mark.parametrize(("isatty_value", "expected"), [(True, True), (False, False)]) def test_main_color_from_isatty(monkeypatch, isatty_value, expected): - if os.getenv("FORCE_COLOR"): - monkeypatch.delenv("FORCE_COLOR") + monkeypatch.delenv("FORCE_COLOR", raising=False) monkeypatch.setattr(sys, "argv", [sys.executable]) with mock.patch("nox.workflow.execute") as execute: execute.return_value = 0 @@ -628,8 +627,7 @@ def test_main_color_from_isatty(monkeypatch, isatty_value, expected): ], ) def test_main_color_options(monkeypatch, color_opt, expected): - if os.getenv("FORCE_COLOR"): - monkeypatch.delenv("FORCE_COLOR") + monkeypatch.delenv("FORCE_COLOR", raising=False) monkeypatch.setattr(sys, "argv", [sys.executable, color_opt]) with mock.patch("nox.workflow.execute") as execute: execute.return_value = 0