/ tests / test_cli.py
test_cli.py
 1  """Tests for the `cli` module."""
 2  
 3  from __future__ import annotations
 4  
 5  import pytest
 6  
 7  from docstrings2pep727 import cli, debug
 8  
 9  
10  def test_main() -> None:
11      """Basic CLI test."""
12      with pytest.raises(SystemExit):
13          cli.main([])
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          cli.main(["-h"])
24      captured = capsys.readouterr()
25      assert "docstrings2pep727" 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          cli.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          cli.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