Coverage for tests/test_tutorial/test_parameter_types/test_enum/test_tutorial004_an.py: 100%
25 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
1import subprocess 1abcdefghi
2import sys 1abcdefghi
4from typer.testing import CliRunner 1abcdefghi
6from docs_src.parameter_types.enum import tutorial004_an as mod 1abcdefghi
8runner = CliRunner() 1abcdefghi
9app = mod.app 1abcdefghi
12def test_help(): 1abcdefghi
13 result = runner.invoke(app, ["--help"]) 1abcdefghi
14 assert result.exit_code == 0 1abcdefghi
15 assert "--network [simple|conv|lstm]" in result.output.replace(" ", "") 1abcdefghi
18def test_main(): 1abcdefghi
19 result = runner.invoke(app, ["--network", "conv"]) 1abcdefghi
20 assert result.exit_code == 0 1abcdefghi
21 assert "Training neural network of type: conv" in result.output 1abcdefghi
24def test_invalid(): 1abcdefghi
25 result = runner.invoke(app, ["--network", "capsule"]) 1abcdefghi
26 assert result.exit_code != 0 1abcdefghi
27 assert "Invalid value for '--network'" in result.output 1abcdefghi
28 assert ( 1abcdefghi
29 "invalid choice: capsule. (choose from" in result.output
30 or "'capsule' is not one of" in result.output
31 )
32 assert "simple" in result.output 1abcdefghi
33 assert "conv" in result.output 1abcdefghi
34 assert "lstm" in result.output 1abcdefghi
37def test_script(): 1abcdefghi
38 result = subprocess.run( 1abcdefghi
39 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
40 capture_output=True,
41 encoding="utf-8",
42 )
43 assert "Usage" in result.stdout 1abcdefghi