Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_help_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 "usage:" in captured.out
assert not captured.err
def test_valid_args(args, desired):
ns = parse_args(shlex.split(args))
actual = vars(ns)
assert actual == desired
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 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 make_dict(**kwargs):
ns = parse_args([])
return dict(vars(ns), **kwargs)