Don't print to stdout when executing hacking checks
The way the hacking tests _run_check works, it ends up evaluating python code in a context where all of our stdout capture has been undone. The pep8 check_all method *also* prints out the errors found, not only accumulating them for later. We can patch out the method doing that to keep this from leaking through the test output, which only causes confusion. Change-Id: I9be4801352c4977504d95123d01bcbe309f22347
This commit is contained in:
parent
dc2f4f88ac
commit
15b392a67b
|
@ -343,7 +343,11 @@ class HackingTestCase(test.NoDBTestCase):
|
|||
lines = textwrap.dedent(code).strip().splitlines(True)
|
||||
|
||||
checker = pep8.Checker(filename=filename, lines=lines)
|
||||
checker.check_all()
|
||||
# NOTE(sdague): the standard reporter has printing to stdout
|
||||
# as a normal part of check_all, which bleeds through to the
|
||||
# test output stream in an unhelpful way. This blocks that printing.
|
||||
with mock.patch('pep8.StandardReport.get_file_results'):
|
||||
checker.check_all()
|
||||
checker.report._deferred_print.sort()
|
||||
return checker.report._deferred_print
|
||||
|
||||
|
|
Loading…
Reference in New Issue