commit: d89ed8c8920204029d02ce001f532bfef0307f69 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Sat Nov 25 06:44:37 2023 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Sat Nov 25 06:45:02 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d89ed8c8
dev-python/pip: Fix testing with NO_COLOR Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> dev-python/pip/files/pip-23.3.1-no-color.patch | 35 ++++++++++++++++++++++++++ dev-python/pip/pip-23.3.1.ebuild | 1 + 2 files changed, 36 insertions(+) diff --git a/dev-python/pip/files/pip-23.3.1-no-color.patch b/dev-python/pip/files/pip-23.3.1-no-color.patch new file mode 100644 index 000000000000..528e2c6cf465 --- /dev/null +++ b/dev-python/pip/files/pip-23.3.1-no-color.patch @@ -0,0 +1,35 @@ +From ad01e9c2a965d395c5902c8ad70c970c7631316b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org> +Date: Sat, 25 Nov 2023 07:36:59 +0100 +Subject: [PATCH] Fix tests when NO_COLOR is set in the calling environment + +Add `FORCE_COLOR` and `NO_COLOR` variables to the `isolate()` fixture +to ensure that these two variables do not affect internal test output. +This fixes the following two test failures when pytest is called with +`NO_COLOR` set: + +``` +FAILED tests/unit/test_exceptions.py::TestDiagnosticPipErrorPresentation_ASCII::test_complete_color - AssertionError: assert '\x1b[1merror...ing harder.\n' == '\x1b[1;31mer...ing harder.\n' +FAILED tests/unit/test_exceptions.py::TestDiagnosticPipErrorPresentation_Unicode::test_complete_color - AssertionError: assert '\x1b[1merror...ing harder.\n' == '\x1b[1;31mer...ing harder.\n' +``` +--- + news/7ae28a10-04c4-4a1f-a276-4c9e04f2e0c1.trivial.rst | 0 + tests/conftest.py | 4 ++++ + 2 files changed, 4 insertions(+) + create mode 100644 news/7ae28a10-04c4-4a1f-a276-4c9e04f2e0c1.trivial.rst + +diff --git a/tests/conftest.py b/tests/conftest.py +index c5bf4bb9567..8d9eb029c79 100644 +--- a/tests/conftest.py ++++ b/tests/conftest.py +@@ -318,6 +318,10 @@ def isolate(tmpdir: Path, monkeypatch: pytest.MonkeyPatch) -> None: + # Make sure tests don't share a requirements tracker. + monkeypatch.delenv("PIP_BUILD_TRACKER", False) + ++ # Make sure color control variables don't affect internal output. ++ monkeypatch.delenv("FORCE_COLOR", False) ++ monkeypatch.delenv("NO_COLOR", False) ++ + # FIXME: Windows... + os.makedirs(os.path.join(home_dir, ".config", "git")) + with open(os.path.join(home_dir, ".config", "git", "config"), "wb") as fp: diff --git a/dev-python/pip/pip-23.3.1.ebuild b/dev-python/pip/pip-23.3.1.ebuild index 58c5279dbfaa..88ef2bad1879 100644 --- a/dev-python/pip/pip-23.3.1.ebuild +++ b/dev-python/pip/pip-23.3.1.ebuild @@ -58,6 +58,7 @@ distutils_enable_tests pytest python_prepare_all() { local PATCHES=( "${FILESDIR}/pip-23.1-no-coverage.patch" + "${FILESDIR}/${P}-no-color.patch" ) distutils-r1_python_prepare_all