@@ -236,6 +236,42 @@ async def hello_with_background_task(
236236 assert task_result == ["Hello Async" ]
237237
238238
239+ async def test_wireup_task_is_resolvable_from_integration_module_registration () -> None :
240+ container = wireup .create_async_container (injectables = [shared_services , wireup .integration .starlette ])
241+
242+ task = await container .get (WireupTask )
243+
244+ assert isinstance (task , WireupTask )
245+ assert task .container is container
246+
247+
248+ def test_setup_still_exposes_wireup_task_without_integration_module_registration () -> None :
249+ task_result : list [str ] = []
250+
251+ def write_logs (name : str , greeter : Injected [GreeterService ]) -> None :
252+ task_result .append (greeter .greet (name ))
253+
254+ @inject
255+ async def hello_with_background_task (
256+ _request : Request ,
257+ wireup_task : Injected [WireupTask ],
258+ ) -> PlainTextResponse :
259+ return PlainTextResponse (
260+ "ok" ,
261+ background = BackgroundTask (wireup_task (write_logs ), "Fallback" ),
262+ )
263+
264+ app = Starlette (routes = [Route ("/hello_bg" , hello_with_background_task , methods = ["GET" ])])
265+ container = wireup .create_async_container (injectables = [shared_services ])
266+ wireup .integration .starlette .setup (container , app )
267+
268+ with TestClient (app ) as client :
269+ response = client .get ("/hello_bg" )
270+
271+ assert response .status_code == 200
272+ assert task_result == ["Hello Fallback" ]
273+
274+
239275def test_background_task_uses_different_scope_than_request () -> None :
240276 ids : dict [str , str ] = {}
241277
0 commit comments