@@ 185-200 (lines=16) @@ | ||
182 | assert run(target(200)) is None |
|
183 | ||
184 | ||
185 | def test_nested_injector_correctly_injects_nested_sync_function_async_nested(): |
|
186 | async def target(x): |
|
187 | async def nested(y): |
|
188 | if y > 100: |
|
189 | return y |
|
190 | ||
191 | if x < 200: |
|
192 | return await nested(x) |
|
193 | ||
194 | @inject(target=target, injector=NestedInjector('nested', TailInjector())) |
|
195 | def handler(): |
|
196 | return -1 |
|
197 | ||
198 | assert run(target(13)) == -1 |
|
199 | assert run(target(101)) == 101 |
|
200 | assert run(target(200)) is None |
|
201 | ||
@@ 167-182 (lines=16) @@ | ||
164 | assert run(target(200)) is None |
|
165 | ||
166 | ||
167 | def test_nested_injector_correctly_injects_async_function_async_nested(): |
|
168 | async def target(x): |
|
169 | async def nested(y): |
|
170 | if y > 100: |
|
171 | return y |
|
172 | ||
173 | if x < 200: |
|
174 | return await nested(x) |
|
175 | ||
176 | @inject(target=target, injector=NestedInjector('nested', TailInjector())) |
|
177 | def handler(): |
|
178 | return -1 |
|
179 | ||
180 | assert run(target(13)) == -1 |
|
181 | assert run(target(101)) == 101 |
|
182 | assert run(target(200)) is None |
|
183 | ||
184 | ||
185 | def test_nested_injector_correctly_injects_nested_sync_function_async_nested(): |
|
@@ 149-164 (lines=16) @@ | ||
146 | assert run(target(101)) == 201 |
|
147 | ||
148 | ||
149 | def test_nested_injector_correctly_injects_async_function_sync_nested(): |
|
150 | async def target(x): |
|
151 | def nested(y): |
|
152 | if y > 100: |
|
153 | return y |
|
154 | ||
155 | if x < 200: |
|
156 | return nested(x) |
|
157 | ||
158 | @inject(target=target, injector=NestedInjector('nested', TailInjector())) |
|
159 | def handler(): |
|
160 | return -1 |
|
161 | ||
162 | assert run(target(13)) == -1 |
|
163 | assert run(target(101)) == 101 |
|
164 | assert run(target(200)) is None |
|
165 | ||
166 | ||
167 | def test_nested_injector_correctly_injects_async_function_async_nested(): |
@@ 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 |