diff options
author | 2016-10-25 13:22:15 +0300 | |
---|---|---|
committer | 2016-10-25 13:34:06 +0000 | |
commit | 749294dfeb597687202fe525de64b55ab653eccd (patch) | |
tree | 69620f21503496938528b4706acf43fc9044aa9f /test | |
parent | 46a4d9f2e7943e14a1708c56e47a3994ef02e6ff (diff) |
Disable colored output for tests, when not tty
Change-Id: I73f01bd3a8e7caa00c75b845b9e61d3cb0f34877
Signed-off-by: Peter Ginchev <pginchev@cisco.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/framework.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/test/framework.py b/test/framework.py index 8bfb5513..5cf2a250 100644 --- a/test/framework.py +++ b/test/framework.py @@ -9,6 +9,7 @@ import logging logging.getLogger("scapy.runtime").setLevel(logging.ERROR) import os +import sys import subprocess import unittest from inspect import getdoc @@ -21,11 +22,19 @@ from scapy.packet import Raw # These variables (RED, GREEN, YELLOW and LPURPLE) are used to configure # the color of the text to be printed in the terminal. Variable END is used # to revert the text color to the default one. -RED = '\033[91m' -GREEN = '\033[92m' -YELLOW = '\033[93m' -LPURPLE = '\033[94m' -END = '\033[0m' +if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty(): + RED = '\033[91m' + GREEN = '\033[92m' + YELLOW = '\033[93m' + LPURPLE = '\033[94m' + END = '\033[0m' +else: + RED = '' + GREEN = '' + YELLOW = '' + LPURPLE = '' + END = '' + ## Private class to create packet info object. # |