-
-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001_str_enum.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import subprocess | ||
import sys | ||
|
||
import typer | ||
from typer.testing import CliRunner | ||
|
||
from docs_src.parameter_types.enum import tutorial001_str_enum as mod | ||
|
||
runner = CliRunner() | ||
|
||
app = typer.Typer() | ||
app.command()(mod.main) | ||
|
||
|
||
def test_help(): | ||
result = runner.invoke(app, ["--help"]) | ||
assert result.exit_code == 0 | ||
assert "--network" in result.output | ||
assert "[simple|conv|lstm]" in result.output | ||
assert "default: simple" in result.output | ||
|
||
|
||
def test_main(): | ||
result = runner.invoke(app, ["--network", "conv"]) | ||
assert result.exit_code == 0 | ||
assert "Training neural network of type: conv" in result.output | ||
|
||
|
||
def test_invalid_case(): | ||
result = runner.invoke(app, ["--network", "CONV"]) | ||
assert result.exit_code != 0 | ||
assert "Invalid value for '--network': 'CONV' is not one of" in result.output | ||
assert "simple" in result.output | ||
assert "conv" in result.output | ||
assert "lstm" in result.output | ||
|
||
|
||
def test_invalid_other(): | ||
result = runner.invoke(app, ["--network", "capsule"]) | ||
assert result.exit_code != 0 | ||
assert "Invalid value for '--network': 'capsule' is not one of" in result.output | ||
assert "simple" in result.output | ||
assert "conv" in result.output | ||
assert "lstm" in result.output | ||
|
||
|
||
def test_script(): | ||
result = subprocess.run( | ||
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], | ||
capture_output=True, | ||
encoding="utf-8", | ||
) | ||
assert "Usage" in result.stdout |
33 changes: 33 additions & 0 deletions
33
tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002_str_enum.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import subprocess | ||
import sys | ||
|
||
import typer | ||
from typer.testing import CliRunner | ||
|
||
from docs_src.parameter_types.enum import tutorial002_str_enum as mod | ||
|
||
runner = CliRunner() | ||
|
||
app = typer.Typer() | ||
app.command()(mod.main) | ||
|
||
|
||
def test_upper(): | ||
result = runner.invoke(app, ["--network", "CONV"]) | ||
assert result.exit_code == 0 | ||
assert "Training neural network of type: conv" in result.output | ||
|
||
|
||
def test_mix(): | ||
result = runner.invoke(app, ["--network", "LsTm"]) | ||
assert result.exit_code == 0 | ||
assert "Training neural network of type: lstm" in result.output | ||
|
||
|
||
def test_script(): | ||
result = subprocess.run( | ||
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], | ||
capture_output=True, | ||
encoding="utf-8", | ||
) | ||
assert "Usage" in result.stdout |