Commits

Ronny Pfannschmidt committed bcc7f2f

complete output and short filenames

Comments (0)

Files changed (3)

codecheckers/flakes.py

 
 Assignment.__init__ = assignment_monkeypatched_init
 
-def check_file(path):
-    return pyflakes_check(path.read(), str(path))
+def check_file(path, filename, io):
+    return pyflakes_check(path.read(), filename, io)
 

codecheckers/pep.py

+import sys
 import pep8
 
 class PyTestChecker(pep8.Checker):
             self.ignored_errors += 1
         pep8.Checker.report_error(self, line_number, offset, text, check)
 
-def check_file(path):
-
-    pep8.process_options(['pep8',
-        # ignore list taken from moin
-        '--ignore=E202,E221,E222,E241,E301,E302,E401,E501,E701,W391,W601,W602',
-        '--show-source',
-        '--repeat',
-        'dummy file',
-        ])
-    checker = PyTestChecker(str(path))
-    #XXX: bails out on death
-    error_count = checker.check_all()
-    ignored = checker.ignored_errors
-    return max(error_count - ignored, 0)
+def check_file(path, filename, io):
+    oldio = sys.stdout, sys.stderr
+    try:
+        sys.stdout = sys.stderr = io
+        pep8.process_options(['pep8',
+            # ignore list taken from moin
+            '--ignore=E202,E221,E222,E241,E301,E302,E401,E501,E701,W391,W601,W602',
+            '--show-source',
+            '--repeat',
+            'dummy file',
+            ])
+        checker = PyTestChecker(filename, path.readlines())
+        #XXX: bails out on death
+        error_count = checker.check_all()
+        ignored = checker.ignored_errors
+        return max(error_count - ignored, 0)
+    finally:
+        sys.stdout , sys.stderr = oldio

codecheckers/plugin.py

         self._ep = ep
 
     def runtest(self):
-        c = py.io.StdCapture()
+        io = py.io.BytesIO()
         mod = self._ep.load()
         try:
-            found_errors, out, err = c.call(mod.check_file, self.fspath)
-            self.out, self.err = out, err
+            main = py.path.local()
+            filename = main.bestrelpath(self.fspath)
+            found_errors = mod.check_file(self.fspath, filename, io)
+            self.out = io.getvalue()
         except:
             found_errors = True
             self.info = py.code.ExceptionInfo()