[tor-commits] [stem/master] Disabling static checks when using python 3.x

atagar at torproject.org atagar at torproject.org
Sat Feb 2 18:20:49 UTC 2013


commit 137aed3eadb184fd3e96828cd207220d3e09a043
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jan 21 09:02:18 2013 -0800

    Disabling static checks when using python 3.x
    
    Not only are our static checks useless with the python 3.x codebase (pyflakes
    probably ins't python 3.x compatable and who cares about PEP8 issues with the
    output?), the pyflake check errors...
    
    Traceback (most recent call last):
      File "./test/data/python3/run_tests.py", line 554, in <module>
        style_issues.update(test.check_whitespace.pyflakes_issues(os.path.join(base_path, "stem")))
      File "/home/atagar/Desktop/stem/test/data/python3/test/check_whitespace.py", line 132, in pyflakes_issues
        line_match = re.match("^(.*):(\d+): (.*)$", line)
      File "/usr/lib/python3.2/re.py", line 153, in match
        return _compile(pattern, flags).match(string)
    TypeError: can't use a string pattern on a bytes-like object
---
 run_tests.py |   77 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 566eb41..c66c9f8 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -338,6 +338,45 @@ def _python3_setup(python3_destination):
   return True
 
 
+def _print_style_issues():
+  base_path = os.path.sep.join(__file__.split(os.path.sep)[:-1]).lstrip("./")
+  style_issues = test.check_whitespace.get_issues(os.path.join(base_path, "stem"))
+  style_issues.update(test.check_whitespace.get_issues(os.path.join(base_path, "test")))
+  style_issues.update(test.check_whitespace.get_issues(os.path.join(base_path, "run_tests.py")))
+
+  # If we're doing some sort of testing (unit or integ) and pyflakes is
+  # available then use it. Its static checks are pretty quick so there's not
+  # much overhead in including it with all tests.
+
+  if CONFIG["argument.unit"] or CONFIG["argument.integ"]:
+    if system.is_available("pyflakes"):
+      style_issues.update(test.check_whitespace.pyflakes_issues(os.path.join(base_path, "stem")))
+      style_issues.update(test.check_whitespace.pyflakes_issues(os.path.join(base_path, "test")))
+      style_issues.update(test.check_whitespace.pyflakes_issues(os.path.join(base_path, "run_tests.py")))
+    else:
+      test.output.print_line("Static error checking requires pyflakes. Please install it from ...\n  http://pypi.python.org/pypi/pyflakes\n", *ERROR_ATTR)
+
+  if CONFIG["argument.style"]:
+    if system.is_available("pep8"):
+      style_issues.update(test.check_whitespace.pep8_issues(os.path.join(base_path, "stem")))
+      style_issues.update(test.check_whitespace.pep8_issues(os.path.join(base_path, "test")))
+      style_issues.update(test.check_whitespace.pep8_issues(os.path.join(base_path, "run_tests.py")))
+    else:
+      test.output.print_line("Style checks require pep8. Please install it from...\n  http://pypi.python.org/pypi/pep8\n", *ERROR_ATTR)
+
+  if style_issues:
+    test.output.print_line("STYLE ISSUES", term.Color.BLUE, term.Attr.BOLD)
+
+    for file_path in style_issues:
+      test.output.print_line("* %s" % file_path, term.Color.BLUE, term.Attr.BOLD)
+
+      for line_number, msg in style_issues[file_path]:
+        line_count = "%-4s" % line_number
+        test.output.print_line("  line %s - %s" % (line_count, msg))
+
+      print
+
+
 if __name__ == '__main__':
   try:
     stem.prereq.check_requirements()
@@ -540,42 +579,8 @@ if __name__ == '__main__':
 
     # TODO: note unused config options afterward?
 
-  base_path = os.path.sep.join(__file__.split(os.path.sep)[:-1]).lstrip("./")
-  style_issues = test.check_whitespace.get_issues(os.path.join(base_path, "stem"))
-  style_issues.update(test.check_whitespace.get_issues(os.path.join(base_path, "test")))
-  style_issues.update(test.check_whitespace.get_issues(os.path.join(base_path, "run_tests.py")))
-
-  # If we're doing some sort of testing (unit or integ) and pyflakes is
-  # available then use it. Its static checks are pretty quick so there's not
-  # much overhead in including it with all tests.
-
-  if CONFIG["argument.unit"] or CONFIG["argument.integ"]:
-    if system.is_available("pyflakes"):
-      style_issues.update(test.check_whitespace.pyflakes_issues(os.path.join(base_path, "stem")))
-      style_issues.update(test.check_whitespace.pyflakes_issues(os.path.join(base_path, "test")))
-      style_issues.update(test.check_whitespace.pyflakes_issues(os.path.join(base_path, "run_tests.py")))
-    else:
-      test.output.print_line("Static error checking requires pyflakes. Please install it from ...\n  http://pypi.python.org/pypi/pyflakes\n", *ERROR_ATTR)
-
-  if CONFIG["argument.style"]:
-    if system.is_available("pep8"):
-      style_issues.update(test.check_whitespace.pep8_issues(os.path.join(base_path, "stem")))
-      style_issues.update(test.check_whitespace.pep8_issues(os.path.join(base_path, "test")))
-      style_issues.update(test.check_whitespace.pep8_issues(os.path.join(base_path, "run_tests.py")))
-    else:
-      test.output.print_line("Style checks require pep8. Please install it from...\n  http://pypi.python.org/pypi/pep8\n", *ERROR_ATTR)
-
-  if style_issues:
-    test.output.print_line("STYLE ISSUES", term.Color.BLUE, term.Attr.BOLD)
-
-    for file_path in style_issues:
-      test.output.print_line("* %s" % file_path, term.Color.BLUE, term.Attr.BOLD)
-
-      for line_number, msg in style_issues[file_path]:
-        line_count = "%-4s" % line_number
-        test.output.print_line("  line %s - %s" % (line_count, msg))
-
-      print
+  if not stem.prereq.is_python_3():
+    _print_style_issues()
 
   runtime = time.time() - start_time
 





More information about the tor-commits mailing list