@@ -526,58 +526,3 @@ async def test_hashed_url_no_etag(static: HashedStatic) -> None:
526526 await static (make_scope (f"/static/{ hashed_name } " ), receive , resp )
527527 assert resp .status == 200
528528 assert b"etag" not in resp .headers , "Hashed URL should not include an etag header"
529-
530-
531- # ── StaticRewriteMiddleware: return value propagation ──────────────
532-
533-
534- async def test_rewrite_middleware_returns_inner_app_result (
535- static : HashedStatic ,
536- ) -> None :
537- """Middleware should propagate the inner app's return value on the HTTP path.
538-
539- ASGI apps normally return None, but the spec does not forbid return values.
540- Frameworks like Starlette rely on ``return await self.app(...)`` so that
541- return values propagate through the middleware chain. A bare ``await``
542- without ``return`` silently discards the result.
543- """
544- sentinel = "app_result"
545-
546- async def inner_app (scope : dict , receive : Any , send : Any ) -> str :
547- body = b"<html>hello</html>"
548- await send (
549- {
550- "type" : "http.response.start" ,
551- "status" : 200 ,
552- "headers" : [
553- (b"content-type" , b"text/html; charset=utf-8" ),
554- (b"content-length" , str (len (body )).encode ("latin-1" )),
555- ],
556- }
557- )
558- await send ({"type" : "http.response.body" , "body" : body })
559- return sentinel
560-
561- app = StaticRewriteMiddleware (inner_app , static = static )
562- resp = ResponseCollector ()
563- result = await app (make_scope ("/" ), receive , resp )
564- assert result == sentinel
565-
566-
567- async def test_rewrite_middleware_returns_inner_app_result_non_http (
568- static : HashedStatic ,
569- ) -> None :
570- """Middleware should propagate the inner app's return value for non-HTTP scopes.
571-
572- When the scope type is not "http", the middleware forwards directly to the
573- inner app. It must ``return await self.app(...)`` so the return value is
574- not silently discarded.
575- """
576- sentinel = "ws_result"
577-
578- async def inner_app (scope : dict , receive : Any , send : Any ) -> str :
579- return sentinel
580-
581- app = StaticRewriteMiddleware (inner_app , static = static )
582- result = await app ({"type" : "websocket" , "path" : "/" }, receive , ResponseCollector ())
583- assert result == sentinel
0 commit comments