Coverage for tests/test_cli.py: 100.00%

21 statements  

« prev     ^ index     » next       coverage.py v7.7.0, created at 2025-03-19 16:19 +0100

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

2 

3from __future__ import annotations 

4 

5from typing import TYPE_CHECKING 

6 

7from yore import main 

8from yore._internal import debug 

9 

10if TYPE_CHECKING: 

11 import pytest 

12 

13 

14def test_main() -> None: 

15 """Basic CLI test.""" 

16 assert main([]) == 2 

17 

18 

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

20 """Show help. 

21 

22 Parameters: 

23 capsys: Pytest fixture to capture output. 

24 """ 

25 assert main(["-h"]) == 0 

26 captured = capsys.readouterr() 

27 assert "yore" 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 assert main(["-V"]) == 0 

37 captured = capsys.readouterr() 

38 assert debug._get_version() in captured.out 

39 

40 

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

42 """Show debug information. 

43 

44 Parameters: 

45 capsys: Pytest fixture to capture output. 

46 """ 

47 assert main(["--debug-info"]) == 0 

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