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