Skip to content

Commit f7b240d

Browse files
✅ Update tests to use mod.app (#1427)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 69c8be6 commit f7b240d

File tree

127 files changed

+132
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+132
-474
lines changed

docs/tutorial/arguments/default.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Hello Camila
5252

5353
And we can even make the default value be dynamically generated by passing a function as the `default_factory` argument:
5454

55-
{* docs_src/arguments/default/tutorial002_an.py hl[10:11,14] *}
55+
{* docs_src/arguments/default/tutorial002_an.py hl[9:10,14] *}
5656

5757
In this case, we created the function `get_name` that will just return a random `str` each time.
5858

docs_src/arguments/default/tutorial002.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
app = typer.Typer()
66

77

8-
@app.command()
98
def get_name():
109
return random.choice(["Deadpool", "Rick", "Morty", "Hiro"])
1110

1211

12+
@app.command()
1313
def main(name: str = typer.Argument(default_factory=get_name)):
1414
print(f"Hello {name}")
1515

docs_src/arguments/default/tutorial002_an.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
app = typer.Typer()
77

88

9-
@app.command()
109
def get_name():
1110
return random.choice(["Deadpool", "Rick", "Morty", "Hiro"])
1211

1312

13+
@app.command()
1414
def main(name: Annotated[str, typer.Argument(default_factory=get_name)]):
1515
print(f"Hello {name}")
1616

tests/test_completion/test_completion_install.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
from unittest import mock
66

77
import shellingham
8-
import typer
98
from typer.testing import CliRunner
109

1110
from docs_src.typer_app import tutorial001 as mod
1211

1312
from ..utils import requires_completion_permission
1413

1514
runner = CliRunner()
16-
app = typer.Typer()
17-
app.command()(mod.main)
15+
app = mod.app
1816

1917

2018
@requires_completion_permission

tests/test_completion/test_completion_show.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
from unittest import mock
55

66
import shellingham
7-
import typer
87
from typer.testing import CliRunner
98

109
from docs_src.typer_app import tutorial001 as mod
1110

1211
runner = CliRunner()
13-
app = typer.Typer()
14-
app.command()(mod.main)
12+
app = mod.app
1513

1614

1715
def test_completion_show_no_shell():

tests/test_tutorial/test_arguments/test_default/test_tutorial001.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import subprocess
22
import sys
33

4-
import typer
54
from typer.testing import CliRunner
65

76
from docs_src.arguments.default import tutorial001 as mod
87

98
runner = CliRunner()
109

11-
app = typer.Typer()
12-
app.command()(mod.main)
10+
app = mod.app
1311

1412

1513
def test_help():

tests/test_tutorial/test_arguments/test_default/test_tutorial001_an.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import subprocess
22
import sys
33

4-
import typer
54
from typer.testing import CliRunner
65

76
from docs_src.arguments.default import tutorial001_an as mod
87

98
runner = CliRunner()
10-
11-
app = typer.Typer()
12-
app.command()(mod.main)
9+
app = mod.app
1310

1411

1512
def test_help():

tests/test_tutorial/test_arguments/test_default/test_tutorial002.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import subprocess
22
import sys
33

4-
import typer
54
from typer.testing import CliRunner
65

76
from docs_src.arguments.default import tutorial002 as mod
87

98
runner = CliRunner()
10-
11-
app = typer.Typer()
12-
app.command()(mod.main)
9+
app = mod.app
1310

1411

1512
def test_help():

tests/test_tutorial/test_arguments/test_default/test_tutorial002_an.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import subprocess
22
import sys
33

4-
import typer
54
from typer.testing import CliRunner
65

76
from docs_src.arguments.default import tutorial002_an as mod
87

98
runner = CliRunner()
10-
11-
app = typer.Typer()
12-
app.command()(mod.main)
9+
app = mod.app
1310

1411

1512
def test_help():

tests/test_tutorial/test_arguments/test_envvar/test_tutorial001.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
from docs_src.arguments.envvar import tutorial001 as mod
1010

1111
runner = CliRunner()
12-
13-
app = typer.Typer()
14-
app.command()(mod.main)
12+
app = mod.app
1513

1614

1715
def test_help():

0 commit comments

Comments
 (0)