Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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