Exemplo n.º 1
0
def test_run_path_subcmd_version(capsys):
    with pytest.raises(SystemExit) as e:
        run(["path", "--version"])

    captured = capsys.readouterr()
    assert e.value.code == 0
    assert "pathins v" in captured.out
Exemplo n.º 2
0
def test_run_path_subcmd_invalid_file(capsys):
    with pytest.raises(SystemExit) as e:
        run(["path", "boguspath"])

    captured = capsys.readouterr()
    assert e.value.code == 1
    assert "does not appear to be a file" in captured.err
Exemplo n.º 3
0
def test_run_missing_subcommand(capsys):
    with pytest.raises(SystemExit) as e:
        run([])

    captured = capsys.readouterr()
    assert e.value.code == 1
    assert "error: please enter a valid sub-command" in captured.err
Exemplo n.º 4
0
def test_run_invalid_subcommand(capsys):
    with pytest.raises(SystemExit) as e:
        run(["boguscmd"])

    captured = capsys.readouterr()
    assert e.value.code == 2
    assert "argument subparser_name: invalid choice" in captured.err
Exemplo n.º 5
0
def test_run_help(capsys):
    with pytest.raises(SystemExit) as e:
        run(["--help"])

    captured = capsys.readouterr()
    assert e.value.code == 0
    assert "usage:" in captured.out
    assert "positional arguments:" in captured.out
    assert "optional arguments:" in captured.out