test_cli.py
1 """Tests for the CLI.""" 2 3 from __future__ import annotations 4 5 import pytest 6 7 from griffe_typedoc import main 8 from griffe_typedoc._internal import debug 9 10 11 def test_main() -> None: 12 """Basic CLI test.""" 13 assert main([]) == 0 14 15 16 def test_show_help(capsys: pytest.CaptureFixture) -> None: 17 """Show help. 18 19 Parameters: 20 capsys: Pytest fixture to capture output. 21 """ 22 with pytest.raises(SystemExit): 23 main(["-h"]) 24 captured = capsys.readouterr() 25 assert "griffe-typedoc" in captured.out 26 27 28 def test_show_version(capsys: pytest.CaptureFixture) -> None: 29 """Show version. 30 31 Parameters: 32 capsys: Pytest fixture to capture output. 33 """ 34 with pytest.raises(SystemExit): 35 main(["-V"]) 36 captured = capsys.readouterr() 37 assert debug._get_version() in captured.out 38 39 40 def test_show_debug_info(capsys: pytest.CaptureFixture) -> None: 41 """Show debug information. 42 43 Parameters: 44 capsys: Pytest fixture to capture output. 45 """ 46 with pytest.raises(SystemExit): 47 main(["--debug-info"]) 48 captured = capsys.readouterr().out.lower() 49 assert "python" in captured 50 assert "system" in captured 51 assert "environment" in captured 52 assert "packages" in captured