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

test.test_error_handling.MyMissingDep.__init__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
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