Total Complexity | 4 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import logging |
||
2 | |||
3 | from lagom import Container |
||
4 | |||
5 | |||
6 | class AThing: |
||
7 | pass |
||
8 | |||
9 | |||
10 | def test_it_writes_a_warning_every_time_reflection_is_used(caplog): |
||
11 | c = Container(log_undefined_deps=True) |
||
12 | with caplog.at_level(logging.INFO): |
||
13 | _something = c[AThing] |
||
14 | |||
15 | assert len(caplog.records) == 1 |
||
16 | assert ( |
||
17 | caplog.records[0].message |
||
18 | == "Undefined dependency. Using reflection for <class 'tests.test_undefinied_dep_logging.AThing'>" |
||
19 | ) |
||
20 | assert caplog.records[0].undefined_dependency == AThing |
||
21 | |||
22 | |||
23 | def test_by_default_it_doesnt_log(caplog): |
||
24 | c = Container() |
||
25 | with caplog.at_level(logging.INFO): |
||
26 | _something = c[AThing] |
||
27 | assert len(caplog.records) == 0 |
||
28 |