Debian Codegraph @

packages/griffecli/tests/test_cli.py

raw symbols SCIP
1 """Tests for the CLI."""
2
3 from __future__ import annotations
4
5 import sys
6
7 import pytest
8
9 from griffe._internal import debug
10 from griffecli._internal import cli
11
12
13 def test_main() -> None:
14 """Basic CLI test."""
15 if sys.platform == "win32":
16 assert cli.main(["dump", "griffe", "-s", "src", "-oNUL"]) == 0
17 else:
18 assert cli.main(["dump", "griffe", "-s", "src", "-o/dev/null"]) == 0
19
20
21 def test_show_help(capsys: pytest.CaptureFixture) -> None:
22 """Show help.
23
24 Parameters:
25 capsys: Pytest fixture to capture output.
26 """
27 with pytest.raises(SystemExit):
28 cli.main(["-h"])
29 captured = capsys.readouterr()
30 assert "griffe" in captured.out
31
32
33 def test_show_version(capsys: pytest.CaptureFixture) -> None:
34 """Show version.
35
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
43
44
45 def test_show_debug_info(capsys: pytest.CaptureFixture) -> None:
46 """Show debug information.
47
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