tests: py: Don't colorize output if stderr is redirected
Phil Sutter
reviewerPATCH 1/1 tests: py: Don't colorize output if stderr is redirected
Cover for calls with '2>/tmp/log' and avoid printing escape sequences to that file. One could still keep colored output on stdout, but that required a printing routine for non-errors.
Signed-off-by Phil Sutter <[email protected]>
--- tests/py/nft-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/py/nft-test.py +1 -1
@@ -39,7 +39,7 @@ signal_received = 0 class Colors: - if sys.stdout.isatty(): + if sys.stdout.isatty() and sys.stderr.isatty(): HEADER = '\033[95m' GREEN = '\033[92m' YELLOW = '\033[93m'
Signature · 1 line
2.34.1
Florian Westphal
maintainerQuoted 3 lines · Phil Sutter
Cover for calls with '2>/tmp/log' and avoid printing escape sequences to that file. One could still keep colored output on stdout, but that required a printing routine for non-errors.
Thanks! Please push.