def test_captured_output(stream_mock): """stdout should be a StringIO in the with statement.""" # Can't assert that stdout is a file because nose may be capturing stdout. mock = stream_mock() with check.captured_output() as stream: assert stream is mock assert sys.stdout is mock
def test_trailing_whitespace(open_mock): m = open_mock.return_value.read.return_value = "foo\nbar \n \n" files = ["foo", "bla.py"] with check.captured_output() as output: check.trailing_whitespace(files) output.reset() # Ignore the banner. output.readline() for n in 2, 3: assert output.readline() == "%s:%s: trailing whitespace\n" % ("foo", n)
def test_trailing_whitespace(open_mock): m = open_mock.return_value.read.return_value = 'foo\nbar \n \n' files = ['foo', 'bla.py'] with check.captured_output() as output: check.trailing_whitespace(files) output.reset() # Ignore the banner. output.readline() for n in 2, 3: assert output.readline() == '%s:%s: trailing whitespace\n' % ('foo', n)