def test_version_option(args, capsys): with pytest.raises(SystemExit) as exc_info: parse_args(shlex.split(args)) assert exc_info.value.code == 0 captured = capsys.readouterr() assert "Python " in captured.out assert not captured.err
def test_invalid_args(args, capsys): with pytest.raises(SystemExit) as exc_info: parse_args(shlex.split(args)) assert exc_info.value.code != 0 captured = capsys.readouterr() assert "usage:" in captured.err assert not captured.out
def make_dict(**kwargs): ns = parse_args([]) return dict(vars(ns), **kwargs)
def test_valid_args(args, desired): ns = parse_args(shlex.split(args)) actual = vars(ns) assert actual == desired