Coverage for tests/test_cli.py: 100.00%

26 statements  

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

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

2 

3from __future__ import annotations 

4 

5import pytest 

6 

7from griffe2md import cli, debug 

8 

9 

10def test_main() -> None: 

11 """Basic CLI test.""" 

12 with pytest.raises(expected_exception=SystemExit): 

13 cli.main([]) 

14 

15 

16def 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 "griffe2md" in captured.out 

26 

27 

28def test_render_self() -> None: 

29 """Render docs for itself.""" 

30 cli.main(["griffe2md", "-o/dev/null"]) 

31 

32 

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

34 """Show version. 

35 

36 Parameters: 

37 capsys: Pytest fixture to capture output. 

38 """ 

39 with pytest.raises(SystemExit): 

40 cli.main(["-V"]) 

41 captured = capsys.readouterr() 

42 assert debug.get_version() in captured.out 

43 

44 

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

46 """Show debug information. 

47 

48 Parameters: 

49 capsys: Pytest fixture to capture output. 

50 """ 

51 with pytest.raises(SystemExit): 

52 cli.main(["--debug-info"]) 

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

54 assert "python" in captured 

55 assert "system" in captured 

56 assert "environment" in captured 

57 assert "packages" in captured