commit: d9106ef568e17f248306bc6bf63471c19beb4612 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Fri Nov 24 15:54:23 2023 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Fri Nov 24 15:56:00 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d9106ef5
dev-python/colorlog: Fix running tests with NO_COLOR=1 Closes: https://bugs.gentoo.org/906700 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> dev-python/colorlog/colorlog-6.7.0.ebuild | 11 ++++++-- .../colorlog/files/colorlog-6.7.0-nocolor.patch | 31 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/dev-python/colorlog/colorlog-6.7.0.ebuild b/dev-python/colorlog/colorlog-6.7.0.ebuild index deeab2c63621..4457b3c16990 100644 --- a/dev-python/colorlog/colorlog-6.7.0.ebuild +++ b/dev-python/colorlog/colorlog-6.7.0.ebuild @@ -5,14 +5,21 @@ EAPI=8 DISTUTILS_USE_PEP517=setuptools PYTHON_COMPAT=( pypy3 python3_{10..12} ) + inherit distutils-r1 pypi DESCRIPTION="Log formatting with colors" -HOMEPAGE="https://pypi.org/project/colorlog/ - https://github.com/borntyping/python-colorlog" +HOMEPAGE=" + https://pypi.org/project/colorlog/ + https://github.com/borntyping/python-colorlog/ +" LICENSE="MIT" SLOT="0" KEYWORDS="amd64 ~arm64 ~riscv x86" distutils_enable_tests pytest + +PATCHES=( + "${FILESDIR}/${P}-nocolor.patch" +) diff --git a/dev-python/colorlog/files/colorlog-6.7.0-nocolor.patch b/dev-python/colorlog/files/colorlog-6.7.0-nocolor.patch new file mode 100644 index 000000000000..cbd799a2f0d7 --- /dev/null +++ b/dev-python/colorlog/files/colorlog-6.7.0-nocolor.patch @@ -0,0 +1,31 @@ +From 4babdb5f18bd4799c25d61f0f7937b5e164770cc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Fri, 24 Nov 2023 16:45:42 +0100 +Subject: [PATCH] Fix running tests in environment with NO_COLOR=1 + +Fix running the test suite when pytest is run with NO_COLOR=1 set +in the environment. An fixture is autoused to ensure that the variables +are removed for the scope of the test, while they are respected +e.g. by pytest itself. +--- + colorlog/tests/conftest.py | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/colorlog/tests/conftest.py b/colorlog/tests/conftest.py +index 65fd6d4..33e23e6 100644 +--- a/colorlog/tests/conftest.py ++++ b/colorlog/tests/conftest.py +@@ -28,6 +28,13 @@ def assert_log_message(capsys, log_function, message, *args): + return err + + [email protected](autouse=True) ++def clean_env(monkeypatch): ++ monkeypatch.delenv("FORCE_COLOR", raising=False) ++ monkeypatch.delenv("NO_COLOR", raising=False) ++ yield ++ ++ + @pytest.fixture() + def reset_loggers(): + logging.root.handlers = list()
