Coverage for tests/test_cli.py: 92.86%
26 statements
« prev ^ index » next coverage.py v7.6.2, created at 2024-10-12 01:34 +0200
« prev ^ index » next coverage.py v7.6.2, created at 2024-10-12 01:34 +0200
1"""Tests for the `cli` module."""
3from __future__ import annotations
5import sys
7import pytest
9from _griffe import cli, debug
12def test_main() -> None:
13 """Basic CLI test."""
14 if sys.platform == "win32": 14 ↛ 15line 14 didn't jump to line 15 because the condition on line 14 was never true
15 assert cli.main(["dump", "griffe", "-s", "src", "-oNUL"]) == 0
16 else:
17 assert cli.main(["dump", "griffe", "-s", "src", "-o/dev/null"]) == 0
20def test_show_help(capsys: pytest.CaptureFixture) -> None:
21 """Show help.
23 Parameters:
24 capsys: Pytest fixture to capture output.
25 """
26 with pytest.raises(SystemExit):
27 cli.main(["-h"])
28 captured = capsys.readouterr()
29 assert "griffe" in captured.out
32def test_show_version(capsys: pytest.CaptureFixture) -> None:
33 """Show version.
35 Parameters:
36 capsys: Pytest fixture to capture output.
37 """
38 with pytest.raises(SystemExit):
39 cli.main(["-V"])
40 captured = capsys.readouterr()
41 assert debug._get_version() in captured.out
44def test_show_debug_info(capsys: pytest.CaptureFixture) -> None:
45 """Show debug information.
47 Parameters:
48 capsys: Pytest fixture to capture output.
49 """
50 with pytest.raises(SystemExit):
51 cli.main(["--debug-info"])
52 captured = capsys.readouterr().out.lower()
53 assert "python" in captured
54 assert "system" in captured
55 assert "environment" in captured
56 assert "packages" in captured