Coverage for tests/test_tutorial/test_options/test_help/test_tutorial002.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-19 20:29 +0000

1import subprocess 1abcdefghi

2import sys 1abcdefghi

3 

4from typer.testing import CliRunner 1abcdefghi

5 

6from docs_src.options.help import tutorial002 as mod 1abcdefghi

7 

8runner = CliRunner() 1abcdefghi

9app = mod.app 1abcdefghi

10 

11 

12def test_call(): 1abcdefghi

13 result = runner.invoke(app, ["World"]) 1abcdefghi

14 assert result.exit_code == 0 1abcdefghi

15 assert "Hello World" in result.output 1abcdefghi

16 

17 

18def test_formal(): 1abcdefghi

19 result = runner.invoke(app, ["World", "--formal"]) 1abcdefghi

20 assert result.exit_code == 0 1abcdefghi

21 assert "Good day Ms. World" in result.output 1abcdefghi

22 

23 

24def test_help(): 1abcdefghi

25 result = runner.invoke(app, ["--help"]) 1abcdefghi

26 assert result.exit_code == 0 1abcdefghi

27 assert "--lastname" in result.output 1abcdefghi

28 assert "Customization and Utils" in result.output 1abcdefghi

29 assert "--formal" in result.output 1abcdefghi

30 assert "--no-formal" in result.output 1abcdefghi

31 assert "--debug" in result.output 1abcdefghi

32 assert "--no-debug" in result.output 1abcdefghi

33 

34 

35def test_script(): 1abcdefghi

36 result = subprocess.run( 1abcdefghi

37 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], 

38 capture_output=True, 

39 encoding="utf-8", 

40 ) 

41 assert "Usage" in result.stdout 1abcdefghi