Skip to content

Commit

Permalink
Adds test for async function
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrodesouzadev committed Jun 24, 2022
1 parent d6b82be commit f493841
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
16 changes: 15 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dev = [
"black>=22.3.0",
"mypy>=0.961",
"pytest>=7.1.2",
"pytest-asyncio>=0.18.3",
]

[build-system]
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
asyncio_mode = strict
12 changes: 11 additions & 1 deletion tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_requires_decorator_must_have_dependency_type_annotated_on_decorated_sig
def f(a: str):
pass

f("a")
f("abc")


def test_requires_decorator_does_not_allow_duplicated_annotation_for_dependency_type():
Expand Down Expand Up @@ -86,6 +86,16 @@ def f(t: T):
f()


@pytest.mark.asyncio
async def test_requires_can_also_wraps_coroutine():
@requires(T)
async def f(t: T):
pass

register_dependency(T())
await f()


def test_provider_decorator_must_be_called_on_function():
with pytest.raises(exc.InvalidFunctionDecoration):

Expand Down

0 comments on commit f493841

Please sign in to comment.