Summary
Can you please add a dependency override to the application. Something similar to fastapi's app.dependency_overrides.
This is important when trying to override a dependency while writing tests.
Basic Example
@pytest.fixture
def client(app):
database = TestAsyncSessionLocal()
def test_get_db(app):
try:
yield database
finally:
database.close()
app.dependency_overrides['db'] = Provide(test_get_db) # nothing like dependency_overrides in starlite
...
Drawbacks and Impact
Here's what I tried:
def client(app):
database = TestAsyncSessionLocal()
def test_get_db(app):
try:
yield database
finally:
database.close()
app.dependencies['db'] = Provide(test_get_db)
...
This doesn't work because handlers are already registered in main:app. So overriding dependencies like this after handlers have been registered changes nothing.
Unresolved questions
No response
Summary
Can you please add a dependency override to the application. Something similar to fastapi's app.dependency_overrides.
This is important when trying to override a dependency while writing tests.
Basic Example
Drawbacks and Impact
Here's what I tried:
This doesn't work because handlers are already registered in main:app. So overriding dependencies like this after handlers have been registered changes nothing.
Unresolved questions
No response