[py-svn] pytest-pycheckers commit 5bef9172457d: use the checker output as replacement for pytest tracebacks
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Feb 13 12:35:41 CET 2010
# HG changeset patch -- Bitbucket.org
# Project pytest-pycheckers
# URL http://bitbucket.org/RonnyPfannschmidt/pytest-pycheckers/overview/
# User Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
# Date 1266060767 -3600
# Node ID 5bef9172457dd0d5cda10ff109b7ec7c83e43bff
# Parent 30bef2ea4ca5e97e53bbe1e54a4ef11d4bafe157
use the checker output as replacement for pytest tracebacks
--- a/codecheckers/plugin.py
+++ b/codecheckers/plugin.py
@@ -9,8 +9,14 @@ class PyCodeCheckItem(py.test.collect.It
self._ep = ep
def runtest(self):
+ c = py.io.StdCapture()
mod = self._ep.load()
- mod.check_file(self.fspath)
+ found_errors, out, err = c.call(mod.check_file, self.fspath)
+ self.out, self.err = out, err
+ assert not found_errors
+
+ def repr_failure(self, exc_info):
+ return self.out
def reportinfo(self):
return (self.fspath, -1, "codecheck")
@@ -21,6 +27,7 @@ class PyCheckerCollector(py.test.collect
def __init__(self, path, parent):
super(PyCheckerCollector, self).__init__(path, parent)
self.name += '[code-check]'
+
def collect(self):
entrypoints = pkg_resources.iter_entry_points('codechecker')
return [PyCodeCheckItem(ep, self) for ep in entrypoints]
--- a/codecheckers/flakes.py
+++ b/codecheckers/flakes.py
@@ -10,5 +10,5 @@ def assignment_monkeypatched_init(self,
Assignment.__init__ = assignment_monkeypatched_init
def check_file(path):
- error_count = pyflakes_check(path.read(), str(path))
- assert not error_count
+ return pyflakes_check(path.read(), str(path))
+
--- a/codecheckers/pep.py
+++ b/codecheckers/pep.py
@@ -18,4 +18,4 @@ def check_file(path):
checker = PyTestChecker(str(path))
error_count = checker.check_all()
ignored = checker.ignored_errors
- assert error_count <= ignored
+ return max(error_count - ignored, 0)
--- a/tests/test_pyflakes.py
+++ b/tests/test_pyflakes.py
@@ -6,8 +6,9 @@ def test_pyflakes_finds_name_error(testd
abc
''')
f.write(f.read() + '\n') #XXX: bad hack cause i fail to disable the pep8 checker
- out = testdir.runpytest('--tb=short', '-k', 'flakes')
+ out = testdir.runpytest('--tb=short', '-k', 'flakes', '-v')
out.stdout.fnmatch_lines([
+ '*abc*',
'*1 failed*',
])
@@ -19,5 +20,5 @@ def test_reportinfo_verbose(testdir):
f.write(f.read() + '\n')
out = testdir.runpytest('-v')
out.stdout.fnmatch_lines([
- '*test_reportinfo_verbose.py: codecheck',
+ '*test_reportinfo_verbose.py: codecheck PASS',
])
More information about the pytest-commit
mailing list