Coverage for tests/test_cli.py: 100.00%
26 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 11:44 +0100
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 11:44 +0100
1"""Tests for the `cli` module."""
3from __future__ import annotations
5import pytest
7from griffe2md import cli, debug
10def test_main() -> None:
11 """Basic CLI test."""
12 with pytest.raises(expected_exception=SystemExit):
13 cli.main([])
16def test_show_help(capsys: pytest.CaptureFixture) -> None:
17 """Show help.
19 Parameters:
20 capsys: Pytest fixture to capture output.
21 """
22 with pytest.raises(SystemExit):
23 cli.main(["-h"])
24 captured = capsys.readouterr()
25 assert "griffe2md" in captured.out
28def test_render_self() -> None:
29 """Render docs for itself."""
30 cli.main(["griffe2md", "-o/dev/null"])
33def test_show_version(capsys: pytest.CaptureFixture) -> None:
34 """Show version.
36 Parameters:
37 capsys: Pytest fixture to capture output.
38 """
39 with pytest.raises(SystemExit):
40 cli.main(["-V"])
41 captured = capsys.readouterr()
42 assert debug.get_version() in captured.out
45def test_show_debug_info(capsys: pytest.CaptureFixture) -> None:
46 """Show debug information.
48 Parameters:
49 capsys: Pytest fixture to capture output.
50 """
51 with pytest.raises(SystemExit):
52 cli.main(["--debug-info"])
53 captured = capsys.readouterr().out.lower()
54 assert "python" in captured
55 assert "system" in captured
56 assert "environment" in captured
57 assert "packages" in captured