test_ok2/testing/io
Michał Górny 52db918a27
Fix handling empty values of NO_COLOR and FORCE_COLOR (#11712)
* Fix handling empty values of NO_COLOR and FORCE_COLOR

Fix handling NO_COLOR and FORCE_COLOR environment variables to correctly
be ignored when they are set to an empty value, as defined
in the specification:

> Command-line software which adds ANSI color to its output by default
> should check for a NO_COLOR environment variable that, when present
> *and not an empty string* (regardless of its value), prevents
> the addition of ANSI color.

(emphasis mine, https://no-color.org/)

The same is true of FORCE_COLOR, https://force-color.org/.

* Streamline testing for FORCE_COLOR and NO_COLOR

Streamline the tests for FORCE_COLOR and NO_COLOR variables, and cover
all possible cases (unset, set to empty, set to "1").  Combine the two
assert functions into one taking boolean parameters.  Mock file.isatty
in all circumstances to ensure that the environment variables take
precedence over the fallback value resulting from isatty check (or that
the fallback is actually used, in the case of both FORCE_COLOR
and NO_COLOR being unset).
2023-12-23 10:12:13 +02:00
..
test_pprint.py Improve the full diff by having more consistent indentation in the PrettyPrinter (#11571) 2023-11-27 16:47:18 +02:00
test_saferepr.py Merge the AlwaysDispathPrettyPrinter into the now vendored PrettyPrinter 2023-11-20 13:00:00 +00:00
test_terminalwriter.py Fix handling empty values of NO_COLOR and FORCE_COLOR (#11712) 2023-12-23 10:12:13 +02:00
test_wcwidth.py Improve our own wcwidth implementation and remove dependency on wcwidth package 2020-05-26 17:14:01 +03:00