Coverage for tests/test_cli.py: 100.00%

23 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-03-19 20:21 +0100

1"""Tests for the `cli` module.""" 

2 

3from __future__ import annotations 

4 

5import pytest 

6 

7from devboard import cli, debug 

8 

9 

10def test_main() -> None: 

11 """Basic CLI test.""" 

12 assert cli.main([]) == 0 

13 

14 

15def 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 "devboard" in captured.out 

25 

26 

27def 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 

39def 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