tests.test_undefinied_dep_logging   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_it_writes_a_warning_every_time_reflection_is_used() 0 11 2
A test_by_default_it_doesnt_log() 0 5 2
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