Coverage for tests / test_corner_cases.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-02-09 12:36 +0000

1import pytest 1abcdefgh

2import typer.core 1abcdefgh

3from typer.testing import CliRunner 1abcdefgh

4 

5from tests.assets import corner_cases as mod 1abcdefgh

6 

7runner = CliRunner() 1abcdefgh

8 

9 

10def test_hidden_option(): 1abcdefgh

11 result = runner.invoke(mod.app, ["--help"]) 1abcdefgh

12 assert result.exit_code == 0 1abcdefgh

13 assert "Say hello" in result.output 1abcdefgh

14 assert "--name" not in result.output 1abcdefgh

15 assert "/lastname" in result.output 1abcdefgh

16 assert "TEST_LASTNAME" in result.output 1abcdefgh

17 assert "(dynamic)" in result.output 1abcdefgh

18 

19 

20def test_hidden_option_no_rich(monkeypatch: pytest.MonkeyPatch): 1abcdefgh

21 monkeypatch.setattr(typer.core, "HAS_RICH", False) 1abcdefgh

22 

23 result = runner.invoke(mod.app, ["--help"]) 1abcdefgh

24 assert result.exit_code == 0 1abcdefgh

25 assert "Say hello" in result.output 1abcdefgh

26 assert "--name" not in result.output 1abcdefgh

27 assert "/lastname" in result.output 1abcdefgh

28 assert "TEST_LASTNAME" in result.output 1abcdefgh

29 assert "(dynamic)" in result.output 1abcdefgh

30 

31 

32def test_coverage_call(): 1abcdefgh

33 result = runner.invoke(mod.app) 1abcdefgh

34 assert result.exit_code == 0 1abcdefgh

35 assert "Hello John Doe, it seems you have 42" in result.output 1abcdefgh