Code Duplication    Length = 15-18 lines in 5 locations

tests/test_injectors/test_inject_decorated_method.py 1 location

@@ 73-90 (lines=18) @@
70
    assert target.target(101) == '202 :)'
71
72
73
def test_return_injector_correctly_injects_decorated_method_ordinal_returns():
74
    class Target:
75
        @decorate
76
        def target(self, x):
77
            if x > 100:
78
                y = x * 2
79
                return y
80
            else:
81
                y = x + 2
82
                return y
83
84
    @inject(target=Target.target, injector=ReturnInjector(ordinal=1))
85
    def handler():
86
        return '{} :)'.format(y)
87
88
    target = Target()
89
    assert target.target(13) == '15 :)'
90
    assert target.target(101) == 202
91
92
93
def test_field_injector_correctly_injects_decorated_method_before_all_fields():

tests/test_injectors/test_inject_static_method.py 1 location

@@ 66-83 (lines=18) @@
63
    assert target.target(101) == '202 :)'
64
65
66
def test_return_injector_correctly_injects_static_method_ordinal_returns():
67
    class Target:
68
        @staticmethod
69
        def target(x):
70
            if x > 100:
71
                y = x * 2
72
                return y
73
            else:
74
                y = x + 2
75
                return y
76
77
    @inject(target=Target.target, injector=ReturnInjector(ordinal=1))
78
    def handler():
79
        return '{} :)'.format(y)
80
81
    target = Target()
82
    assert target.target(13) == '15 :)'
83
    assert target.target(101) == 202
84
85
86
def test_field_injector_correctly_injects_static_method_before_all_fields():

tests/test_injectors/test_inject_method.py 2 locations

@@ 63-79 (lines=17) @@
60
    assert target.target(101) == '202 :)'
61
62
63
def test_return_injector_correctly_injects_method_ordinal_returns():
64
    class Target:
65
        def target(self, x):
66
            if x > 100:
67
                y = x * 2
68
                return y
69
            else:
70
                y = x + 2
71
                return y
72
73
    @inject(target=Target.target, injector=ReturnInjector(ordinal=1))
74
    def handler():
75
        return '{} :)'.format(y)
76
77
    target = Target()
78
    assert target.target(13) == '15 :)'
79
    assert target.target(101) == 202
80
81
82
def test_field_injector_correctly_injects_method_before_all_fields():
@@ 44-60 (lines=17) @@
41
    assert target.target(101) == 101
42
43
44
def test_return_injector_correctly_injects_method_all_returns():
45
    class Target:
46
        def target(self, x):
47
            if x > 100:
48
                y = x * 2
49
                return y
50
            else:
51
                y = x + 2
52
                return y
53
54
    @inject(target=Target.target, injector=ReturnInjector())
55
    def handler():
56
        return '{} :)'.format(y)
57
58
    target = Target()
59
    assert target.target(13) == '15 :)'
60
    assert target.target(101) == '202 :)'
61
62
63
def test_return_injector_correctly_injects_method_ordinal_returns():

tests/test_injectors/test_inject_async_function.py 1 location

@@ 66-80 (lines=15) @@
63
    assert run(target(101)) == '202 :)'
64
65
66
def test_return_injector_correctly_injects_async_function_ordinal_returns():
67
    async def target(x):
68
        if x > 100:
69
            y = x * 2
70
            return y
71
        else:
72
            y = x + 2
73
            return y
74
75
    @inject(target=target, injector=ReturnInjector(ordinal=1))
76
    def handler():
77
        return '{} :)'.format(y)
78
79
    assert run(target(13)) == '15 :)'
80
    assert run(target(101)) == 202
81
82
83
def test_field_injector_correctly_injects_async_function_before_all_fields():