tests.test_explicit_partial_functions   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 6

5 Functions

Rating   Name   Duplication   Size   Complexity  
A test_async_functions_decorated_get_the_correct_argument() 0 3 1
A test_functions_decorated_get_the_correct_argument() 0 2 1
A test_injected_arguments_can_over_overridden() 0 2 1
A example_function() 0 3 1
A async_example_function() 0 3 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A MyDep.__init__() 0 2 1
1
import pytest
2
3
from lagom import Container, bind_to_container, injectable
4
5
6
class MyDep:
7
    value: str
8
9
    def __init__(self, value="testing"):
10
        self.value = value
11
12
13
container = Container()
14
15
16
@bind_to_container(container)
17
def example_function(message: str, resolved: MyDep = injectable) -> str:
18
    return resolved.value + message
19
20
21
@bind_to_container(container)
22
async def async_example_function(message: str, resolved: MyDep = injectable) -> str:
23
    return resolved.value + message
24
25
26
def test_functions_decorated_get_the_correct_argument():
27
    assert example_function(message=" world") == "testing world"
28
29
30
def test_injected_arguments_can_over_overridden():
31
    assert example_function(message=" world", resolved=MyDep("set")) == "set world"
32
33
34
@pytest.mark.asyncio
35
async def test_async_functions_decorated_get_the_correct_argument():
36
    assert await async_example_function(message=" world") == "testing world"
37