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