[tor-commits] [stem/master] Dropping argument.no_color
atagar at torproject.org
atagar at torproject.org
Sun Apr 14 04:33:46 UTC 2013
commit 930e3608cfef3678357f9e4ad4168f24da19ddf6
Author: Damian Johnson <atagar at torproject.org>
Date: Thu Apr 11 08:44:23 2013 -0700
Dropping argument.no_color
Disabling output colorization stopped being a runner argument a long time ago.
Like git, stem's test runner makes a pretty good guess about if colored output
is supported or not. If it's wrong then we can fix the check.
---
run_tests.py | 5 -----
test/output.py | 40 ++++++++++++++++++----------------------
test/settings.cfg | 1 -
3 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/run_tests.py b/run_tests.py
index 3de1fbf..42ff22e 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -38,7 +38,6 @@ CONFIG = stem.util.conf.config_dict("test", {
"argument.test": "",
"argument.log": None,
"argument.tor": "tor",
- "argument.no_color": False,
"msg.help": "",
"target.config": {},
"target.description": {},
@@ -83,10 +82,6 @@ def load_user_configuration(test_config):
print "%s (for usage provide --help)" % exc
sys.exit(1)
- # suppress color output if our output is being piped
- if (not sys.stdout.isatty()) or system.is_windows():
- arg_overrides["argument.no_color"] = "true"
-
for opt, arg in opts:
if opt in ("-a", "--all"):
arg_overrides["argument.unit"] = "true"
diff --git a/test/output.py b/test/output.py
index 17c457e..66e19c6 100644
--- a/test/output.py
+++ b/test/output.py
@@ -9,14 +9,11 @@ together for improved readability.
import re
import sys
-import stem.util.conf
import stem.util.enum
-from stem.util import term
+from stem.util import system, term
-CONFIG = stem.util.conf.config_dict("test", {
- "argument.no_color": False,
-})
+COLOR_SUPPORT = sys.stdout.isatty() and not system.is_windows()
DIVIDER = "=" * 70
HEADER_ATTR = (term.Color.CYAN, term.Attr.BOLD)
@@ -41,19 +38,18 @@ LINE_ATTR = {
def print_line(msg, *attr):
- if CONFIG["argument.no_color"]:
- print msg
- else:
- print term.format(msg, *attr)
+ if COLOR_SUPPORT:
+ msg = term.format(msg, *attr)
+
+ print msg
def print_noline(msg, *attr):
- if CONFIG["argument.no_color"]:
- sys.stdout.write(msg)
- sys.stdout.flush()
- else:
- sys.stdout.write(term.format(msg, *attr))
- sys.stdout.flush()
+ if COLOR_SUPPORT:
+ msg = term.format(msg, *attr)
+
+ sys.stdout.write(msg)
+ sys.stdout.flush()
def print_divider(msg, is_header = False):
@@ -128,10 +124,10 @@ def colorize(line_type, line_content):
Applies escape sequences so each line is colored according to its type.
"""
- if CONFIG["argument.no_color"]:
- return line_content
- else:
- return term.format(line_content, *LINE_ATTR[line_type])
+ if COLOR_SUPPORT:
+ line_content = term.format(line_content, *LINE_ATTR[line_type])
+
+ return line_content
def strip_module(line_type, line_content):
@@ -177,10 +173,10 @@ def align_results(line_type, line_content):
assert False, "Unexpected line type: %s" % line_type
return line_content
- if CONFIG["argument.no_color"]:
- return "%-61s[%s]" % (line_content, term.format(new_ending))
- else:
+ if COLOR_SUPPORT:
return "%-61s[%s]" % (line_content, term.format(new_ending, term.Attr.BOLD))
+ else:
+ return "%-61s[%s]" % (line_content, term.format(new_ending))
class ErrorTracker(object):
diff --git a/test/settings.cfg b/test/settings.cfg
index d75b7d7..cebee31 100644
--- a/test/settings.cfg
+++ b/test/settings.cfg
@@ -42,7 +42,6 @@ argument.style false
argument.test
argument.log
argument.tor tor
-argument.no_color false
integ.test_directory ./test/data
integ.log ./test/data/log
More information about the tor-commits
mailing list