]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: py: Don't colorize output if stderr is redirected
authorPhil Sutter <phil@nwl.cc>
Thu, 7 Apr 2022 11:53:05 +0000 (13:53 +0200)
committerPhil Sutter <phil@nwl.cc>
Fri, 8 Apr 2022 14:21:32 +0000 (16:21 +0200)
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 <phil@nwl.cc>
tests/py/nft-test.py

index 04dac8d77b25f2c51c971d2409d39998de4a01bc..b66a33c21f661e9ceb969891b77766b74d03f48c 100755 (executable)
@@ -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'