I\'d like to invoke the pylint checker, limited to the Error signalling part, as part of my unit testing. so I checked the pylint executable script, got to the pylint
Instead of creating a WritableObject class we can use StringIO. StringIO contains write method.
import sys
try:
from io import StringIO
except:
from StringIO import StringIO
stdout = sys.stdout
sys.stdout = StringIO()
ARGS = ["-r","n", "--rcfile=rcpylint"]
r = lint.Run(['../test.py']+ARGS, exit=False)
test = sys.stdout.getvalue()
sys.stdout.close()
sys.stdout = stdout
print (test.split('\n'))
Source:
@cdarke 's answer
@mad7777's answer