tests.test_container_clone_layering.Dep.__init__()   A
last analyzed

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
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