Completed
Pull Request — master (#6)
by Steve
02:52 queued 43s
created

test.test_error_handling   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 18
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A UnfulfilledDeps.__init__() 0 2 1
A MyMissingDep.__init__() 0 2 1

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_simple_objects_cannot_be_resolved() 0 4 2
A test_raises_error_with_the_dep_that_couldnt_be_built() 0 4 2
1
import pytest
2
3
from lagom import Container
4
from lagom.exceptions import UnresolvableType
5
6
7
class MyMissingDep:
8
    def __init__(self, _stuff: str):
9
        pass
10
11
12
class UnfulfilledDeps:
13
    def __init__(self, _stuff: MyMissingDep):
14
        pass
15
16
17
@pytest.mark.parametrize("dep", [str, int, float, bool])
18
def test_simple_objects_cannot_be_resolved(container: Container, dep):
19
    with pytest.raises(UnresolvableType):
20
        container.resolve(dep)
21
22
23
def test_raises_error_with_the_dep_that_couldnt_be_built(container):
24
    with pytest.raises(UnresolvableType) as e_info:
25
        container.resolve(UnfulfilledDeps)
26
    assert str(e_info.value) == "Cannot construct type UnfulfilledDeps"
27