Skip to content

Commit

Permalink
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jul 13, 2023
1 parent baed02d commit f63ae5d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/tutorial/async-cmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Typer allows you to use [async](https://docs.python.org/3/library/asyncio.html)
<div class="termy">

```console
$ python async.py
$ python async.py

Hello Async World
```
Expand Down
1 change: 1 addition & 0 deletions docs_src/async_cmd/async001.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio

import typer

app = typer.Typer()
Expand Down
1 change: 1 addition & 0 deletions docs_src/async_cmd/async002.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio

import typer

app = typer.Typer()
Expand Down
13 changes: 10 additions & 3 deletions tests/test_tutorial/test_async_cmd/test_async001.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import subprocess
import sys
import pytest

import pytest
import typer
from typer.testing import CliRunner

from docs_src.async_cmd import async001 as mod

runner = CliRunner()

@pytest.mark.skipif(sys.version_info < (3, 7), reason="typer support for async functions requires python3.7 or higher")

@pytest.mark.skipif(
sys.version_info < (3, 7),
reason="typer support for async functions requires python3.7 or higher",
)
def test_cli():
app = typer.Typer()
app.command()(mod.main)
result = runner.invoke(app, [])
assert result.output == "Hello Async World\n"


@pytest.mark.skipif(sys.version_info < (3, 7), reason="typer support for async functions requires python3.7 or higher")
@pytest.mark.skipif(
sys.version_info < (3, 7),
reason="typer support for async functions requires python3.7 or higher",
)
def test_execute():
result = subprocess.run(
[sys.executable, "-m", "coverage", "run", mod.__file__],
Expand Down
13 changes: 8 additions & 5 deletions tests/test_tutorial/test_async_cmd/test_async002.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import subprocess
import sys
import pytest

import typer
import pytest
from typer.testing import CliRunner

from docs_src.async_cmd import async002 as mod
Expand All @@ -11,12 +10,16 @@

runner = CliRunner()


def test_command_sync():
result = runner.invoke(app, ["sync"])
assert result.output == "Hello Sync World\n"


@pytest.mark.skipif(sys.version_info < (3, 7), reason="typer support for async functions requires python3.7 or higher")
@pytest.mark.skipif(
sys.version_info < (3, 7),
reason="typer support for async functions requires python3.7 or higher",
)
def test_command_async():
result = runner.invoke(app, ["async"])
assert result.output == "Hello Async World\n"
Expand All @@ -40,8 +43,8 @@ def test_execute_async():
encoding="utf-8",
)
assert result.stdout == "Hello Async World\n"


def test_script():
result = subprocess.run(
[sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
Expand Down

0 comments on commit f63ae5d

Please sign in to comment.