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