tests.test_shorter_syntax.MySimpleDep.__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 abc import ABC
2
3
from lagom import Container
4
5
6
class MySimpleDep:
7
    stuff: str
8
9
    def __init__(self, stuff):
10
        self.stuff = stuff
11
12
13
class MyMoreComplicatedDep:
14
    stuff: str
15
16
    def __init__(self, dep: MySimpleDep):
17
        self.stuff = dep.stuff
18
19
20
class AnotherAbc(ABC):
21
    stuff: str = "empty"
22
23
24
class AnotherConcrete(AnotherAbc):
25
    stuff = "full"
26
27
28
def test_deps_can_be_referenced_by_square_brackets(container: Container):
29
    container[MySimpleDep] = lambda: MySimpleDep("hooray")
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable MySimpleDep does not seem to be defined.
Loading history...
30
    resolved = container[MySimpleDep]
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable MySimpleDep does not seem to be defined.
Loading history...
31
    assert resolved.stuff == "hooray"
32
33
34
def test_construction_type_can_be_omitted(container: Container):
35
    container[MySimpleDep] = lambda: MySimpleDep("hooray")
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable MySimpleDep does not seem to be defined.
Loading history...
36
    resolved = container[MySimpleDep]
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable MySimpleDep does not seem to be defined.
Loading history...
37
    assert resolved.stuff == "hooray"
38
39
40
def test_singleton_type_can_be_omitted(container: Container):
41
    container[MySimpleDep] = MySimpleDep("hooray")
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable MySimpleDep does not seem to be defined.
Loading history...
42
    one = container[MySimpleDep]
43
    two = container[MySimpleDep]
44
    assert one is not None
45
    assert one is two
46
47
48
def test_alias_can_be_omitted(container: Container):
49
    container[AnotherAbc] = AnotherConcrete
50
    resolved = container[AnotherAbc]
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable AnotherAbc does not seem to be defined.
Loading history...
51
    assert type(resolved) == AnotherConcrete
52
    assert resolved.stuff == "full"
53