Coverage for tests / test_tutorial / test_parameter_types / test_enum / test_tutorial001.py: 100%
39 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
1import subprocess 1abcdefgh
2import sys 1abcdefgh
4from typer.testing import CliRunner 1abcdefgh
6from docs_src.parameter_types.enum import tutorial001_py39 as mod 1abcdefgh
8runner = CliRunner() 1abcdefgh
9app = mod.app 1abcdefgh
12def test_help(): 1abcdefgh
13 result = runner.invoke(app, ["--help"]) 1abcdefgh
14 assert result.exit_code == 0 1abcdefgh
15 assert "--network" in result.output 1abcdefgh
16 assert "[simple|conv|lstm]" in result.output 1abcdefgh
17 assert "default: simple" in result.output 1abcdefgh
20def test_main(): 1abcdefgh
21 result = runner.invoke(app, ["--network", "conv"]) 1abcdefgh
22 assert result.exit_code == 0 1abcdefgh
23 assert "Training neural network of type: conv" in result.output 1abcdefgh
26def test_main_default(): 1abcdefgh
27 result = runner.invoke(app) 1abcdefgh
28 assert result.exit_code == 0 1abcdefgh
29 assert "Training neural network of type: simple" in result.output 1abcdefgh
32def test_invalid_case(): 1abcdefgh
33 result = runner.invoke(app, ["--network", "CONV"]) 1abcdefgh
34 assert result.exit_code != 0 1abcdefgh
35 assert "Invalid value for '--network'" in result.output 1abcdefgh
36 assert "'CONV' is not one of" in result.output 1abcdefgh
37 assert "simple" in result.output 1abcdefgh
38 assert "conv" in result.output 1abcdefgh
39 assert "lstm" in result.output 1abcdefgh
42def test_invalid_other(): 1abcdefgh
43 result = runner.invoke(app, ["--network", "capsule"]) 1abcdefgh
44 assert result.exit_code != 0 1abcdefgh
45 assert "Invalid value for '--network'" in result.output 1abcdefgh
46 assert "'capsule' is not one of" in result.output 1abcdefgh
47 assert "simple" in result.output 1abcdefgh
48 assert "conv" in result.output 1abcdefgh
49 assert "lstm" in result.output 1abcdefgh
52def test_script(): 1abcdefgh
53 result = subprocess.run( 1abcdefgh
54 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
55 capture_output=True,
56 encoding="utf-8",
57 )
58 assert "Usage" in result.stdout 1abcdefgh