예제 #1
0
파일: tests.py 프로젝트: jbalogh/check
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
예제 #2
0
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
예제 #3
0
파일: tests.py 프로젝트: jbalogh/check
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)
예제 #4
0
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)