コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
def make_dict(**kwargs):
    ns = parse_args([])
    return dict(vars(ns), **kwargs)
コード例 #6
0
def test_valid_args(args, desired):
    ns = parse_args(shlex.split(args))
    actual = vars(ns)
    assert actual == desired
コード例 #7
0
def make_dict(**kwargs):
    ns = parse_args([])
    return dict(vars(ns), **kwargs)
コード例 #8
0
def test_valid_args(args, desired):
    ns = parse_args(shlex.split(args))
    actual = vars(ns)
    assert actual == desired