# HG changeset patch # User Matthieu Laneuville # Date 1500329966 -32400 # Node ID 2893face0af516bfae3133eabe4692820dfeebd7 # Parent d4df141f90d16b4da392ed27265be8e116788763 run-tests: check if stream is a tty before using color Previous implementation (e80041832eec) checked only if sys.stderr was a tty which was less general. Also makes sure that colors is never used if pygments is not available, irrespective of --color flag value. diff -r d4df141f90d1 -r 2893face0af5 tests/run-tests.py --- a/tests/run-tests.py Fri Jul 14 21:44:29 2017 -0700 +++ b/tests/run-tests.py Tue Jul 18 07:19:26 2017 +0900 @@ -101,9 +101,6 @@ except ImportError: pass -if not sys.stderr.isatty(): # check if the terminal is capable - with_color = False - if sys.version_info > (3, 5, 0): PYTHON3 = True xrange = range # we use xrange in one place, and we'd rather not use range @@ -416,13 +413,6 @@ parser.error('--chg does not work when --with-hg is specified ' '(use --with-chg instead)') - global with_color - if options.color != 'auto': - if options.color == 'never': - with_color = False - else: # 'always', for testing purposes - with_color = True - global useipv6 if options.ipv6: useipv6 = checksocketfamily('AF_INET6') @@ -1574,6 +1564,17 @@ self.successes = [] self.faildata = {} + global with_color + if not self.stream.isatty(): # check if the terminal is capable + with_color = False + + if options.color != 'auto': + if options.color == 'never': + with_color = False + else: # 'always', for testing purposes + if pygmentspresent: + with_color = True + def addFailure(self, test, reason): self.failures.append((test, reason))