def test_output(arg, ext, expected, mode): f = tempfile.NamedTemporaryFile('w', suffix='.{0}'.format(ext), delete=False) f.close() try: cli.main(['test', arg, f.name]) f = open(f.name, mode=mode) val = f.read(len(expected)) f.close() assert expected == val finally: os.unlink(f.name)
def test_terminal(capsys): cli.main(['test']) out, err = capsys.readouterr() assert out assert '' == err
def test_unsupported_fileformat(): with pytest.raises(SystemExit) as e: cli.main(['--output=test.pdf', '"This is a test"']) assert 1 == e.exception.code assert e.exception.message
def test_unsupported_color(): with pytest.raises(SystemExit) as e: cli.main(['--color=test', '--output=test.png', '"This is a test"']) assert 1 == e.exception.code assert e.exception.message
def test_error_code(): with pytest.raises(SystemExit) as e: cli.main(['--version=41', '"This is a test"']) assert 1 == e.exception.code assert e.exception.message