-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Labels
Description
Hi!
I discovered that dependency overriding does not work with Litestar. I provide you with two tests with which you can try to reproduce the error:
def test_litestar_di_override_fail_on_provider_override() -> None:
with TestClient(app=app) as client:
with DIContainer.int_fn.override_context(12345364758999):
response = client.get("/router/controller/handler")
assert response.status_code == HTTP_200_OK, response.text
assert response.json() == {
"app_dependency": False,
"controller_dependency": ["some"],
"local_dependency": 12345364758999, # ASSERTION ERROR HERE
"router_dependency": "",
}
def test_litestar_di_override_fail_on_override_providers() -> None:
overrides = {
'int_fn': 12345364758999,
}
with TestClient(app=app) as client:
with DIContainer.override_providers(overrides):
response = client.get("/router/controller/handler")
assert response.status_code == HTTP_200_OK, response.text
assert response.json() == {
"app_dependency": False,
"controller_dependency": ["some"],
"local_dependency": 12345364758999, # ASSERTION ERROR HERE
"router_dependency": "",
}
I haven’t yet figured out what’s going on: in the overriding logic or the litestar itself
Litestar version: 2.12.1
that-depends version: latest