def test_show_help(capsys): """ Show help. Arguments: capsys: Pytest fixture to capture output. """ with pytest.raises(SystemExit): cli.main(["-h"]) captured = capsys.readouterr() assert "failprint" in captured.out
def test_accept_custom_format(capsys): """ Run a command with a custom output format. Arguments: capsys: Pytest fixture to capture output. """ assert cli.main(["--no-progress", "-f", "custom={{output}}", "echo", "custom"]) == 0 outerr = capsys.readouterr() assert "custom" in outerr.out
def test_fail_without_arguments(): """Fails without arguments.""" with pytest.raises(SystemExit): cli.main([])
def test_run_command(): """Run a simple command.""" assert cli.main(["echo", "hello"]) == 0
""" Entry-point module, in case you use `python -m failprint`. Why does this file exist, and why `__main__`? For more info, read: - https://www.python.org/dev/peps/pep-0338/ - https://docs.python.org/3/using/cmdline.html#cmdoption-m """ import sys from failprint.cli import main if __name__ == "__main__": sys.exit(main(sys.argv[1:]))