| Total Complexity | 6 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 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 |