Total Complexity | 4 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import inspect |
||
2 | |||
3 | import pytest |
||
4 | |||
5 | from lagom import Container, bind_to_container |
||
6 | |||
7 | |||
8 | class Something: |
||
9 | pass |
||
10 | |||
11 | |||
12 | def test_partial_application_async_functions_pass_iscoroutinefunction( |
||
13 | container: Container, |
||
14 | ): |
||
15 | @bind_to_container(container) |
||
16 | async def example_async_function(message: str) -> str: |
||
17 | return message |
||
18 | |||
19 | assert inspect.iscoroutinefunction(example_async_function) |
||
20 | |||
21 | |||
22 | def test_partial_application_async_functions_with_shared_pass_iscoroutinefunction( |
||
23 | container: Container, |
||
24 | ): |
||
25 | @bind_to_container(container, shared=[Something]) |
||
26 | async def example_async_function(message: str) -> str: |
||
27 | return message |
||
28 | |||
29 | assert inspect.iscoroutinefunction(example_async_function) |
||
30 | |||
31 | |||
32 | @pytest.mark.asyncio |
||
33 | async def test_calling_async_partials_works_as_expected(container: Container): |
||
34 | @bind_to_container(container) |
||
35 | async def example_async_function(message: str) -> str: |
||
36 | return message |
||
37 | |||
38 | assert await example_async_function("test") == "test" |
||
39 | |||
40 | |||
41 | @pytest.mark.asyncio |
||
42 | async def test_calling_async_partials_works_as_expected_with_shared_too( |
||
43 | container: Container, |
||
44 | ): |
||
45 | @bind_to_container(container, shared=[Something]) |
||
46 | async def example_async_function(message: str) -> str: |
||
47 | return message |
||
48 | |||
49 | assert await example_async_function("test") == "test" |
||
50 |