Coverage for tests / test_tutorial / test_parameter_types / test_uuid / test_tutorial001.py: 100%

18 statements  

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

1import subprocess 1abcdefgh

2import sys 1abcdefgh

3 

4from typer.testing import CliRunner 1abcdefgh

5 

6from docs_src.parameter_types.uuid import tutorial001_py39 as mod 1abcdefgh

7 

8runner = CliRunner() 1abcdefgh

9app = mod.app 1abcdefgh

10 

11 

12def test_main(): 1abcdefgh

13 result = runner.invoke(app, ["d48edaa6-871a-4082-a196-4daab372d4a1"]) 1abcdefgh

14 assert result.exit_code == 0 1abcdefgh

15 assert "USER_ID is d48edaa6-871a-4082-a196-4daab372d4a1" in result.output 1abcdefgh

16 assert "UUID version is: 4" in result.output 1abcdefgh

17 

18 

19def test_invalid_uuid(): 1abcdefgh

20 result = runner.invoke(app, ["7479706572-72756c6573"]) 1abcdefgh

21 assert result.exit_code != 0 1abcdefgh

22 assert ( 1abcdefgh

23 "Invalid value for 'USER_ID': '7479706572-72756c6573' is not a valid UUID" 

24 in result.output 

25 ) 

26 

27 

28def test_script(): 1abcdefgh

29 result = subprocess.run( 1abcdefgh

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

31 capture_output=True, 

32 encoding="utf-8", 

33 ) 

34 assert "Usage" in result.stdout 1abcdefgh