Skip to content

Commit 6a3d9ba

Browse files
committed
use mod as fixture
1 parent 01e0f26 commit 6a3d9ba

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
from typer import Typer
88
from typer.testing import CliRunner
99

10-
from docs_src.parameter_types.enum import tutorial002 as mod
1110
from tests.utils import needs_py311
1211

1312
runner = CliRunner()
1413

1514

1615
@pytest.fixture(
17-
name="app",
16+
name="mod",
1817
params=[
1918
"tutorial002",
2019
"tutorial002_an",
@@ -23,25 +22,22 @@
2322
)
2423
def get_app(request: pytest.FixtureRequest):
2524
mod = importlib.import_module(f"docs_src.parameter_types.enum.{request.param}")
25+
return mod
2626

27-
app = typer.Typer()
28-
app.command()(mod.main)
29-
return app
3027

31-
32-
def test_upper(app: Typer):
33-
result = runner.invoke(app, ["--network", "CONV"])
28+
def test_upper(mod):
29+
result = runner.invoke(mod.app, ["--network", "CONV"])
3430
assert result.exit_code == 0
3531
assert "Training neural network of type: conv" in result.output
3632

3733

38-
def test_mix(app: Typer):
39-
result = runner.invoke(app, ["--network", "LsTm"])
34+
def test_mix(mod):
35+
result = runner.invoke(mod.app, ["--network", "LsTm"])
4036
assert result.exit_code == 0
4137
assert "Training neural network of type: lstm" in result.output
4238

4339

44-
def test_script(app: Typer):
40+
def test_script(mod):
4541
result = subprocess.run(
4642
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
4743
capture_output=True,

0 commit comments

Comments
 (0)