tests.test_container_clone_layering   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Dep.__init__() 0 2 1
A OtherDepNeedingALambda.__init__() 0 2 1
A OtherDep.__init__() 0 2 1

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_container_invocation_level_controls_the_dep_loaded_for_reflected_constructions() 0 4 1
A test_container_invocation_level_is_passed_to_lambdas() 0 4 1
1
from lagom import Container
2
3
4
class Dep:
5
    def __init__(self, contents: str):
6
        self.contents = contents
7
8
9
class OtherDep:
10
    def __init__(self, dep: Dep):
11
        self.dep = dep
12
13
14
class OtherDepNeedingALambda:
15
    def __init__(self, dep):
16
        self.dep = dep
17
18
19
level_one = Container()
20
level_one[Dep] = Dep("level one")
21
level_one[OtherDepNeedingALambda] = lambda c: OtherDepNeedingALambda(c[Dep])
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable OtherDepNeedingALambda does not seem to be defined.
Loading history...
22
23
level_two = level_one.clone()
24
level_two[Dep] = Dep("level two")
25
26
level_three = level_two.clone()
27
level_three[Dep] = Dep("level three")
28
29
30
def test_container_invocation_level_controls_the_dep_loaded_for_reflected_constructions():
31
    assert level_one[OtherDep].dep.contents == "level one"
32
    assert level_two[OtherDep].dep.contents == "level two"
33
    assert level_three[OtherDep].dep.contents == "level three"
34
35
36
def test_container_invocation_level_is_passed_to_lambdas():
37
    assert level_one[OtherDepNeedingALambda].dep.contents == "level one"
38
    assert level_two[OtherDepNeedingALambda].dep.contents == "level two"
39
    assert level_three[OtherDepNeedingALambda].dep.contents == "level three"
40