commit:     654fe46bff76b019a28e73ddfc2027d56e3aea20
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 11 07:33:11 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jan 13 12:08:12 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=654fe46b

python-utils-r1.eclass: epytest, force color output to match NOCOLOR

Force pytest color output on or off based on the presence and value
of NOCOLOR envvar.  This fixes inconsistent use of colors that largely
depended on upstream pytest settings.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/python-utils-r1.eclass | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index ff5b350cd469..aece257e8cba 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1297,6 +1297,16 @@ epytest() {
 
        _python_check_EPYTHON
 
+       local color
+       case ${NOCOLOR} in
+               true|yes)
+                       color=no
+                       ;;
+               *)
+                       color=yes
+                       ;;
+       esac
+
        local args=(
                # verbose progress reporting and tracebacks
                -vv
@@ -1308,6 +1318,8 @@ epytest() {
                # override filterwarnings=error, we do not really want -Werror
                # for end users, as it tends to fail on new warnings from deps
                -Wdefault
+               # override color output
+               "--color=${color}"
        )
        local x
        for x in "${EPYTEST_DESELECT[@]}"; do

Reply via email to