Ejemplo n.º 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)
Ejemplo n.º 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
        )
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 6
0
def test_malformed_utf8_from_stdin_with_filters(stdin):
    with stdin:
        assert main(['--red', 'a']) == 0
Ejemplo n.º 7
0
def test_malformed_utf8_from_stdin_with_filters(stdin):
    with stdin:
        assert main(['--red', 'a']) == 0
Ejemplo n.º 8
0
def test_malformed_utf8_from_command(stdin):
    with stdin:
        assert main(['cat', 'tests/data/UTF-8-test.txt']) == 0
Ejemplo n.º 9
0
def test_malformed_utf8_from_command(stdin):
    with stdin:
        assert main(['cat', 'tests/data/UTF-8-test.txt']) == 0
Ejemplo n.º 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 == ''
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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 == ''
Ejemplo n.º 18
0
def test_malformed_utf8_from_stdin(stdin):
    with stdin:
        assert main([]) == 0
Ejemplo n.º 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
Ejemplo n.º 20
0
def test_malformed_utf8_from_stdin(stdin):
    with stdin:
        assert main([]) == 0