示例#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)