make pylint plugin not bail out early, still does nothing useful, though
--HG-- branch : 1.0.x
This commit is contained in:
parent
1a570011fe
commit
66cf2d3092
|
@ -4,38 +4,33 @@ XXX: Currently in progress, NOT IN WORKING STATE.
|
||||||
"""
|
"""
|
||||||
import py
|
import py
|
||||||
|
|
||||||
lint = py.test.importorskip("pylint")
|
pylint = py.test.importorskip("pylint.lint")
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
group = parser.addgroup('pylint options')
|
group = parser.addgroup('pylint options')
|
||||||
group.addoption('--pylint', action='store_true',
|
group.addoption('--pylint', action='store_true',
|
||||||
default=False, dest='pylint',
|
default=False, dest='pylint',
|
||||||
help='Pylint coverate of test files.')
|
help='run pylint on python files.')
|
||||||
|
|
||||||
def pytest_collect_file(path, parent):
|
def pytest_collect_file(path, parent):
|
||||||
if path.ext == ".py":
|
if path.ext == ".py":
|
||||||
if parent.config.getvalue('pylint'):
|
if parent.config.getvalue('pylint'):
|
||||||
return PylintItem(path, parent, self.lint)
|
return PylintItem(path, parent)
|
||||||
|
|
||||||
def pytest_terminal_summary(terminalreporter):
|
#def pytest_terminal_summary(terminalreporter):
|
||||||
print 'placeholder for pylint output'
|
# print 'placeholder for pylint output'
|
||||||
|
|
||||||
class PylintItem(py.test.collect.Item):
|
class PylintItem(py.test.collect.Item):
|
||||||
def __init__(self, path, parent, lintlib):
|
|
||||||
name = self.__class__.__name__ + ":" + path.basename
|
|
||||||
super(PylintItem, self).__init__(name=name, parent=parent)
|
|
||||||
self.fspath = path
|
|
||||||
self.lint = lintlib
|
|
||||||
|
|
||||||
def runtest(self):
|
def runtest(self):
|
||||||
# run lint here
|
|
||||||
capture = py.io.StdCaptureFD()
|
capture = py.io.StdCaptureFD()
|
||||||
#pylib.org has docs on py.io.stdcaptureFD
|
try:
|
||||||
self.linter = self.lint.PyLinter() #TODO: should this be in the PylintPlugin?
|
linter = pylint.lint.PyLinter()
|
||||||
self.linter.check(str(self.fspath))
|
linter.check(str(self.fspath))
|
||||||
|
finally:
|
||||||
out, err = capture.reset()
|
out, err = capture.reset()
|
||||||
rating = out.strip().split('\n')[-1]
|
rating = out.strip().split('\n')[-1]
|
||||||
print ">>>",
|
print ">>>",
|
||||||
print rating
|
print rating
|
||||||
|
assert 0
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue