tests.test_partial_async_functions   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 4

4 Functions

Rating   Name   Duplication   Size   Complexity  
A test_partial_application_async_functions_pass_iscoroutinefunction() 0 8 1
A test_calling_async_partials_works_as_expected() 0 7 1
A test_partial_application_async_functions_with_shared_pass_iscoroutinefunction() 0 8 1
A test_calling_async_partials_works_as_expected_with_shared_too() 0 9 1
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