Files
pytest2/_py/test/plugin/pytest_pylint.py
holger krekel 5791c06bf2 rewrote the initpkg mechanism and moved py lib implementation files to
_py/...  with py/__init__.py containing pointers into them

The new apipkg is only around 70 lines of code and allows
us to get rid of the infamous "py.__." by regular non-magical
"_py." imports. It is also available as a separately installable
package, see http://bitbucket.org/hpk42/apipkg

--HG--
branch : trunk
2009-10-03 01:47:39 +02:00

37 lines
989 B
Python

"""pylint plugin
XXX: Currently in progress, NOT IN WORKING STATE.
"""
import py
pylint = py.test.importorskip("pylint.lint")
def pytest_addoption(parser):
group = parser.addgroup('pylint options')
group.addoption('--pylint', action='store_true',
default=False, dest='pylint',
help='run pylint on python files.')
def pytest_collect_file(path, parent):
if path.ext == ".py":
if parent.config.getvalue('pylint'):
return PylintItem(path, parent)
#def pytest_terminal_summary(terminalreporter):
# print 'placeholder for pylint output'
class PylintItem(py.test.collect.Item):
def runtest(self):
capture = py.io.StdCaptureFD()
try:
linter = pylint.lint.PyLinter()
linter.check(str(self.fspath))
finally:
out, err = capture.reset()
rating = out.strip().split('\n')[-1]
sys.stdout.write(">>>")
print(rating)
assert 0