Beispiel #1
0
def test_error(capfd, stdin, filter):
    with stdin:
        assert main(['--' + filter.long_option]) == 1
        out, err = capfd.readouterr()
        assert out == ''
        assert re.match(
            r'.*rainbow error: %s option requires (an|1) argument\nrainbow: Usage: .*'
            % ('--' + filter.long_option), err)
Beispiel #2
0
def test_error(capfd, stdin, filter):
    with stdin:
        assert main(['--' + filter.long_option]) == 1
        out, err = capfd.readouterr()
        assert out == ''
        assert re.match(
            r'.*rainbow error: %s option requires (an|1) argument\nrainbow: Usage: .*' % ('--' + filter.long_option),
            err
        )
Beispiel #3
0
def test_warning(capfd, stdin):
    with stdin:
        assert main(['--config', 'does-not-exist', 'true']) == 0
        out, err = capfd.readouterr()
        assert out == ansi.ANSI_RESET_ALL
        assert err == 'rainbow warning: Could not resolve config "does-not-exist"\n' + ansi.ANSI_RESET_ALL
Beispiel #4
0
def test_false(capfd, stdin):
    with stdin:
        assert main(['false']) == 1
        out, err = capfd.readouterr()
        assert out == ansi.ANSI_RESET_ALL
        assert err == ansi.ANSI_RESET_ALL
Beispiel #5
0
def test_true(capfd, stdin):
    with stdin:
        assert main(['true']) == 0
        out, err = capfd.readouterr()
        assert out == ansi.ANSI_RESET_ALL
        assert err == ansi.ANSI_RESET_ALL
Beispiel #6
0
def test_malformed_utf8_from_stdin_with_filters(stdin):
    with stdin:
        assert main(['--red', 'a']) == 0
Beispiel #7
0
def test_malformed_utf8_from_stdin_with_filters(stdin):
    with stdin:
        assert main(['--red', 'a']) == 0
Beispiel #8
0
def test_malformed_utf8_from_command(stdin):
    with stdin:
        assert main(['cat', 'tests/data/UTF-8-test.txt']) == 0
Beispiel #9
0
def test_malformed_utf8_from_command(stdin):
    with stdin:
        assert main(['cat', 'tests/data/UTF-8-test.txt']) == 0
Beispiel #10
0
def test_read_from_stdin(capfd, stdin):
    with stdin:
        assert main([]) == 0
        out, err = capfd.readouterr()
        assert out == "line\n" + ansi.ANSI_RESET_ALL
        assert err == ''
Beispiel #11
0
def test_stacktrace(capfd, stdin):
    with stdin:
        assert main(['--does-not-exist']) == 1
        out, err = capfd.readouterr()
        assert out == ''
        assert 'No such file or directory' in err
Beispiel #12
0
def test_warning(capfd, stdin):
    with stdin:
        assert main(['--config', 'does-not-exist', 'true']) == 0
        out, err = capfd.readouterr()
        assert out == ansi.ANSI_RESET_ALL
        assert err == 'rainbow warning: Could not resolve config "does-not-exist"\n' + ansi.ANSI_RESET_ALL
Beispiel #13
0
def test_false(capfd, stdin):
    with stdin:
        assert main(['false']) == 1
        out, err = capfd.readouterr()
        assert out == ansi.ANSI_RESET_ALL
        assert err == ansi.ANSI_RESET_ALL
Beispiel #14
0
def test_true(capfd, stdin):
    with stdin:
        assert main(['true']) == 0
        out, err = capfd.readouterr()
        assert out == ansi.ANSI_RESET_ALL
        assert err == ansi.ANSI_RESET_ALL
Beispiel #15
0
def test_stacktrace(capfd, stdin):
    with stdin:
        assert main(['--does-not-exist']) == 1
        out, err = capfd.readouterr()
        assert out == ''
        assert 'No such file or directory' in err
Beispiel #16
0
def test_malformed_utf8_from_command_with_filters(stdin):
    with stdin:
        assert main(['--red', 'a', 'cat', 'tests/data/UTF-8-test.txt']) == 0
Beispiel #17
0
def test_read_from_stdin(capfd, stdin):
    with stdin:
        assert main([]) == 0
        out, err = capfd.readouterr()
        assert out == "line\n" + ansi.ANSI_RESET_ALL
        assert err == ''
Beispiel #18
0
def test_malformed_utf8_from_stdin(stdin):
    with stdin:
        assert main([]) == 0
Beispiel #19
0
def test_malformed_utf8_from_command_with_filters(stdin):
    with stdin:
        assert main(['--red', 'a', 'cat', 'tests/data/UTF-8-test.txt']) == 0
Beispiel #20
0
def test_malformed_utf8_from_stdin(stdin):
    with stdin:
        assert main([]) == 0