Skip to content

Commit

Permalink
Merge pull request #44 from melvinkcx/bugfixes/update_starlette_test_…
Browse files Browse the repository at this point in the history
…cases

update Starlette-specific test cases for starlette>=0.24
  • Loading branch information
melvinkcx authored Feb 19, 2023
2 parents 0219f48 + 3409e09 commit 91b298f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/middleware/test_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ async def handle(self, event: Event) -> None:
dummy_handler_1 = DummyHandler()
dummy_handler_2 = DummyHandler()

_ = Starlette(middleware=[
_app = Starlette(middleware=[
Middleware(EventHandlerASGIMiddleware,
handlers=[dummy_handler_1, dummy_handler_2],
middleware_id=middleware_id)])

# Starlette started building the middleware stack lazily since version 0.24
# Ref: https://github.com/encode/starlette/releases/tag/0.24.0
_app.build_middleware_stack()

if middleware_id is None:
with pytest.raises(LookupError, match=r"^<ContextVar name='fastapi_middleware_identifier' at"):
dispatch(event_name="new event", payload={"id": "fail"}, middleware_id=middleware_id)
Expand Down

0 comments on commit 91b298f

Please sign in to comment.