Coverage for tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001.py: 100%
35 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-14 00:18 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-14 00:18 +0000
1import subprocess 1abcdefghi
2import sys 1abcdefghi
4import typer 1abcdefghi
5from typer.testing import CliRunner 1abcdefghi
7from docs_src.parameter_types.enum import tutorial001 as mod 1abcdefghi
9runner = CliRunner() 1abcdefghi
11app = typer.Typer() 1abcdefghi
12app.command()(mod.main) 1abcdefghi
15def test_help(): 1abcdefghi
16 result = runner.invoke(app, ["--help"]) 1abcdefghi
17 assert result.exit_code == 0 1abcdefghi
18 assert "--network" in result.output 1abcdefghi
19 assert "[simple|conv|lstm]" in result.output 1abcdefghi
20 assert "default: simple" in result.output 1abcdefghi
23def test_main(): 1abcdefghi
24 result = runner.invoke(app, ["--network", "conv"]) 1abcdefghi
25 assert result.exit_code == 0 1abcdefghi
26 assert "Training neural network of type: conv" in result.output 1abcdefghi
29def test_invalid_case(): 1abcdefghi
30 result = runner.invoke(app, ["--network", "CONV"]) 1abcdefghi
31 assert result.exit_code != 0 1abcdefghi
32 assert "Invalid value for '--network': 'CONV' is not one of" in result.output 1abcdefghi
33 assert "simple" in result.output 1abcdefghi
34 assert "conv" in result.output 1abcdefghi
35 assert "lstm" in result.output 1abcdefghi
38def test_invalid_other(): 1abcdefghi
39 result = runner.invoke(app, ["--network", "capsule"]) 1abcdefghi
40 assert result.exit_code != 0 1abcdefghi
41 assert "Invalid value for '--network': 'capsule' is not one of" in result.output 1abcdefghi
42 assert "simple" in result.output 1abcdefghi
43 assert "conv" in result.output 1abcdefghi
44 assert "lstm" in result.output 1abcdefghi
47def test_script(): 1abcdefghi
48 result = subprocess.run( 1abcdefghi
49 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
50 capture_output=True,
51 encoding="utf-8",
52 )
53 assert "Usage" in result.stdout 1abcdefghi