[tor-commits] [stem/master] Dropping direct term usage in run_tests.py

atagar at torproject.org atagar at torproject.org
Sun Apr 14 04:33:47 UTC 2013


commit 8a09c4951afb3b806a75fed00e70f280287a76f2
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Apr 13 12:54:51 2013 -0700

    Dropping direct term usage in run_tests.py
    
    Our use of the output module is trending more toward printing message
    categories rather than specific terminal attributes. This will let us customize
    how things are rendered through the output module rather than chasing down all
    of the individual println() calls.
---
 run_tests.py   |   17 ++++++++---------
 test/output.py |    2 ++
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index f47511c..a2f093e 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -19,18 +19,17 @@ import stem.prereq
 import stem.util.conf
 import stem.util.enum
 
-from stem.util import log, system, term
+from stem.util import log, system
 
 import test.output
 import test.runner
 import test.util
 
-from test.output import println, STATUS, ERROR, NO_NL
+from test.output import println, STATUS, SUCCESS, ERROR, NO_NL
 from test.runner import Target
 
 OPT = "auist:l:h"
 OPT_EXPANDED = ["all", "unit", "integ", "style", "python3", "clean", "targets=", "test=", "log=", "tor=", "help"]
-DIVIDER = "=" * 70
 
 CONFIG = stem.util.conf.config_dict("test", {
   "msg.help": "",
@@ -121,10 +120,10 @@ def _print_static_issues(run_unit, run_integ, run_style):
       println("Style checks require pep8. Please install it from...\n  http://pypi.python.org/pypi/pep8\n", ERROR)
 
   if static_check_issues:
-    println("STATIC CHECKS", term.Color.BLUE, term.Attr.BOLD)
+    println("STATIC CHECKS", STATUS)
 
     for file_path in static_check_issues:
-      println("* %s" % file_path, term.Color.BLUE, term.Attr.BOLD)
+      println("* %s" % file_path, STATUS)
 
       for line_number, msg in static_check_issues[file_path]:
         line_count = "%-4s" % line_number
@@ -366,7 +365,7 @@ if __name__ == '__main__':
 
         integ_runner.start(target, attribute_targets, tor_path, extra_torrc_opts = torrc_opts)
 
-        println("Running tests...\n", term.Color.BLUE, term.Attr.BOLD)
+        println("Running tests...\n", STATUS)
 
         for test_class in test.util.get_integ_tests(test_prefix):
           test.output.print_divider(test_class.__module__)
@@ -431,9 +430,9 @@ if __name__ == '__main__':
     for line in error_tracker:
       println("  %s" % line, ERROR)
   elif skipped_test_count > 0:
-    println("%i TESTS WERE SKIPPED" % skipped_test_count, term.Color.BLUE, term.Attr.BOLD)
-    println("ALL OTHER TESTS PASSED %s\n" % runtime_label, term.Color.GREEN, term.Attr.BOLD)
+    println("%i TESTS WERE SKIPPED" % skipped_test_count, STATUS)
+    println("ALL OTHER TESTS PASSED %s\n" % runtime_label, SUCCESS)
   else:
-    println("TESTING PASSED %s\n" % runtime_label, term.Color.GREEN, term.Attr.BOLD)
+    println("TESTING PASSED %s\n" % runtime_label, SUCCESS)
 
   sys.exit(1 if has_error else 0)
diff --git a/test/output.py b/test/output.py
index f174c7b..d965e76 100644
--- a/test/output.py
+++ b/test/output.py
@@ -25,6 +25,8 @@ NO_NL = "no newline"
 
 STATUS = (term.Color.BLUE, term.Attr.BOLD)
 SUBSTATUS = (term.Color.BLUE, )
+
+SUCCESS = (term.Color.GREEN, term.Attr.BOLD)
 ERROR = (term.Color.RED, term.Attr.BOLD)
 
 LineType = stem.util.enum.Enum("OK", "FAIL", "ERROR", "SKIPPED", "CONTENT")





More information about the tor-commits mailing list