Coverage for tests/test_tutorial/test_parameter_types/test_uuid/test_tutorial001.py: 100%
20 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
1import subprocess 1abcdefgh
2import sys 1abcdefgh
4import typer 1abcdefgh
5from typer.testing import CliRunner 1abcdefgh
7from docs_src.parameter_types.uuid import tutorial001 as mod 1abcdefgh
9runner = CliRunner() 1abcdefgh
11app = typer.Typer() 1abcdefgh
12app.command()(mod.main) 1abcdefgh
15def test_main(): 1abcdefgh
16 result = runner.invoke(app, ["d48edaa6-871a-4082-a196-4daab372d4a1"]) 1abcdefgh
17 assert result.exit_code == 0 1abcdefgh
18 assert "USER_ID is d48edaa6-871a-4082-a196-4daab372d4a1" in result.output 1abcdefgh
19 assert "UUID version is: 4" in result.output 1abcdefgh
22def test_invalid_uuid(): 1abcdefgh
23 result = runner.invoke(app, ["7479706572-72756c6573"]) 1abcdefgh
24 assert result.exit_code != 0 1abcdefgh
25 assert ( 1abcdefgh
26 "Invalid value for 'USER_ID': '7479706572-72756c6573' is not a valid UUID"
27 in result.output
28 )
31def test_script(): 1abcdefgh
32 result = subprocess.run( 1abcdefgh
33 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
34 capture_output=True,
35 encoding="utf-8",
36 )
37 assert "Usage" in result.stdout 1abcdefgh