Coverage for tests/test_cli.py: 100.00%

26 statements  

« prev     ^ index     » next       coverage.py v7.10.5, created at 2025-08-24 18:36 +0200

1"""Tests for the CLI.""" 

2 

3from __future__ import annotations 

4 

5import pytest 

6 

7from dependenpy import main 

8from dependenpy._internal import debug 

9 

10 

11def test_main() -> None: 

12 """Basic CLI test.""" 

13 with pytest.raises(SystemExit) as exit: # noqa: PT012 

14 main([]) 

15 assert exit.code == 2 # type: ignore[attr-defined] 

16 

17 

18def test_show_help(capsys: pytest.CaptureFixture) -> None: 

19 """Show help. 

20 

21 Parameters: 

22 capsys: Pytest fixture to capture output. 

23 """ 

24 with pytest.raises(SystemExit): 

25 main(["-h"]) 

26 captured = capsys.readouterr() 

27 assert "dependenpy" in captured.out 

28 

29 

30def test_show_version(capsys: pytest.CaptureFixture) -> None: 

31 """Show version. 

32 

33 Parameters: 

34 capsys: Pytest fixture to capture output. 

35 """ 

36 with pytest.raises(SystemExit): 

37 main(["-v"]) 

38 captured = capsys.readouterr() 

39 assert debug._get_version() in captured.out 

40 

41 

42def test_show_debug_info(capsys: pytest.CaptureFixture) -> None: 

43 """Show debug information. 

44 

45 Parameters: 

46 capsys: Pytest fixture to capture output. 

47 """ 

48 with pytest.raises(SystemExit): 

49 main(["--debug-info"]) 

50 captured = capsys.readouterr().out.lower() 

51 assert "python" in captured 

52 assert "system" in captured 

53 assert "environment" in captured 

54 assert "packages" in captured