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