Exemple #1
0
def test_too_deep(caplog) -> None:
    """Test that there is a maximum allowed depth."""
    with pytest.raises(SystemExit) as exc:
        main(["--max-depth", str(5), "depinfo"])
    assert exc.value.code == 2

    assert any(
        msg == "The maximum depth must be >=0 and <5." for msg in caplog.messages
    )
Exemple #2
0
def test_help(capsys, options: List[str]) -> None:
    """Expect the help message to be shown."""
    with pytest.raises(SystemExit) as exc:
        main(options)
    assert exc.value.code == 0

    captured = capsys.readouterr()
    assert "usage:" in captured.out
    assert "positional arguments:" in captured.out
Exemple #3
0
def test_markdown_format(capsys) -> None:
    """Expect the dependency information in markdown format."""
    main(["--markdown", "depinfo"])

    captured = capsys.readouterr()

    assert "### Platform Information" in captured.out
    assert f"| {platform.system()} " in captured.out
    assert f"| {platform.python_implementation()} " in captured.out

    assert "### Dependency Information" in captured.out
    assert "| depinfo " in captured.out

    assert "### Build Tools Information" in captured.out
    assert "| pip " in captured.out
    assert "| setuptools " in captured.out
    assert "| wheel " in captured.out
Exemple #4
0
def test_simple_format(capsys) -> None:
    """Expect the dependency information in simple format."""
    main(["depinfo"])

    captured = capsys.readouterr()
    lines = captured.out.split("\n")

    assert lines[1].startswith("Platform Information")
    assert lines[2].startswith("--------------------")

    assert lines[3].startswith(platform.system())
    assert lines[4].startswith(platform.python_implementation())

    assert lines[6].startswith("Dependency Information")
    assert lines[7].startswith("----------------------")

    assert any(line.startswith("depinfo") for line in lines[8:])
    assert any(line.startswith("pip") for line in lines[8:])
    assert any(line.startswith("setuptools") for line in lines[8:])
    assert any(line.startswith("wheel") for line in lines[8:])
Exemple #5
0
def test_max_depth(depth: int) -> None:
    """Test that different dependency nesting depths can be requested."""
    main(["--max-depth", str(depth), "depinfo"])