[py-svn] pytest-codecheckers commit 5165ec2a67c2: made code-checking a opt-in via the codecheck option

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Jul 15 12:13:37 CEST 2010


# HG changeset patch -- Bitbucket.org
# Project pytest-codecheckers
# URL http://bitbucket.org/RonnyPfannschmidt/pytest-codecheckers/overview
# User Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
# Date 1279188625 -7200
# Node ID 5165ec2a67c27c58a344bc9ca431845c695efa07
# Parent  c63af42df1d36fb346ef27394ecc069b381b45fb
made code-checking a opt-in via the codecheck option

--- a/codecheckers/plugin.py
+++ b/codecheckers/plugin.py
@@ -36,11 +36,15 @@ class PyCheckerCollector(py.test.collect
         self.name += '[code-check]'
 
     def collect(self):
+        checkers = py.test.config.getvalue('codecheck')
         entrypoints = pkg_resources.iter_entry_points('codechecker')
-        return [PyCodeCheckItem(ep, self) for ep in entrypoints]
+        return [PyCodeCheckItem(ep, self) for ep in entrypoints if ep.name in checkers]
 
 
 def pytest_collect_file(path, parent):
     if path.ext == '.py':
         return PyCheckerCollector(path, parent)
 
+
+def pytest_addoption(parser):
+    parser.addoption('--codecheck', action='append', default=[])

--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,1 @@
+option_codecheck = 'pep8', 'pyflakes'

--- a/tests/test_pyflakes.py
+++ b/tests/test_pyflakes.py
@@ -7,7 +7,7 @@ def test_pyflakes_finds_name_error(testd
         ''')
     #XXX: bad hack cause i fail to disable the pep8 checker
     f.write(f.read() + '\n')
-    out = testdir.runpytest('--tb=short', '-k', 'flakes', '-v')
+    out = testdir.runpytest('--tb=short', '--codecheck=pyflakes', '-k', 'flakes', '-v')
     out.stdout.fnmatch_lines([
         '*abc*',
         '*1 failed*',
@@ -19,7 +19,7 @@ def test_reportinfo_verbose(testdir):
             pass
         ''')
     f.write(f.read() + '\n')
-    out = testdir.runpytest('-v')
+    out = testdir.runpytest('-v', '--codecheck=pyflakes')
     out.stdout.fnmatch_lines([
         '*test_reportinfo_verbose.py: codecheck pyflakes PASS',
         ])



More information about the pytest-commit mailing list