tests/test_injectors/test_inject_decorated_method.py 1 location
|
@@ 173-191 (lines=19) @@
|
| 170 |
|
assert target.target(101) == 201 |
| 171 |
|
|
| 172 |
|
|
| 173 |
|
def test_nested_injector_correctly_injects_decorated_method(): |
| 174 |
|
class Target: |
| 175 |
|
@decorate |
| 176 |
|
def target(self, x): |
| 177 |
|
def nested(y): |
| 178 |
|
if y > 100: |
| 179 |
|
return y |
| 180 |
|
|
| 181 |
|
if x < 200: |
| 182 |
|
return nested(x) |
| 183 |
|
|
| 184 |
|
@inject(target=Target.target, injector=NestedInjector('nested', TailInjector())) |
| 185 |
|
def handler(): |
| 186 |
|
return -1 |
| 187 |
|
|
| 188 |
|
target = Target() |
| 189 |
|
assert target.target(13) == -1 |
| 190 |
|
assert target.target(101) == 101 |
| 191 |
|
assert target.target(200) is None |
| 192 |
|
|
tests/test_injectors/test_inject_static_method.py 1 location
|
@@ 166-184 (lines=19) @@
|
| 163 |
|
assert target.target(101) == 201 |
| 164 |
|
|
| 165 |
|
|
| 166 |
|
def test_nested_injector_correctly_injects_static_method(): |
| 167 |
|
class Target: |
| 168 |
|
@staticmethod |
| 169 |
|
def target(x): |
| 170 |
|
def nested(y): |
| 171 |
|
if y > 100: |
| 172 |
|
return y |
| 173 |
|
|
| 174 |
|
if x < 200: |
| 175 |
|
return nested(x) |
| 176 |
|
|
| 177 |
|
@inject(target=Target.target, injector=NestedInjector('nested', TailInjector())) |
| 178 |
|
def handler(): |
| 179 |
|
return -1 |
| 180 |
|
|
| 181 |
|
target = Target() |
| 182 |
|
assert target.target(13) == -1 |
| 183 |
|
assert target.target(101) == 101 |
| 184 |
|
assert target.target(200) is None |
| 185 |
|
|
tests/test_injectors/test_inject_method.py 1 location
|
@@ 158-175 (lines=18) @@
|
| 155 |
|
assert target.target(101) == 201 |
| 156 |
|
|
| 157 |
|
|
| 158 |
|
def test_nested_injector_correctly_injects_method(): |
| 159 |
|
class Target: |
| 160 |
|
def target(self, x): |
| 161 |
|
def nested(y): |
| 162 |
|
if y > 100: |
| 163 |
|
return y |
| 164 |
|
|
| 165 |
|
if x < 200: |
| 166 |
|
return nested(x) |
| 167 |
|
|
| 168 |
|
@inject(target=Target.target, injector=NestedInjector('nested', TailInjector())) |
| 169 |
|
def handler(): |
| 170 |
|
return -1 |
| 171 |
|
|
| 172 |
|
target = Target() |
| 173 |
|
assert target.target(13) == -1 |
| 174 |
|
assert target.target(101) == 101 |
| 175 |
|
assert target.target(200) is None |
| 176 |
|
|
tests/test_injectors/test_inject_function.py 1 location
|
@@ 140-155 (lines=16) @@
|
| 137 |
|
assert target(101) == 201 |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
def test_nested_injector_correctly_injects_function(): |
| 141 |
|
def target(x): |
| 142 |
|
def nested(y): |
| 143 |
|
if y > 100: |
| 144 |
|
return y |
| 145 |
|
|
| 146 |
|
if x < 200: |
| 147 |
|
return nested(x) |
| 148 |
|
|
| 149 |
|
@inject(target=target, injector=NestedInjector('nested', TailInjector())) |
| 150 |
|
def handler(): |
| 151 |
|
return -1 |
| 152 |
|
|
| 153 |
|
assert target(13) == -1 |
| 154 |
|
assert target(101) == 101 |
| 155 |
|
assert target(200) is None |
| 156 |
|
|