Skip to content

Commit d642491

Browse files
sentrivanaclaude
andauthored
fix(starlette): Update test for Starlette 1.0 TemplateResponse API (#5525)
## Summary - Fix `test_template_tracing_meta` failure on `starlette==1.0.0rc1` across all Python versions (3.10, 3.13, 3.14, 3.14t) Closes #5523 ## Analysis Starlette 1.0.0rc1 removed the deprecated `TemplateResponse(name, context)` calling convention ([Kludex/starlette#3118](Kludex/starlette#3118), commit [`96479da`](Kludex/starlette@96479da)). The new required signature is `TemplateResponse(request, name, context)`. When the old-style call was made, the string template name was passed as the `request` parameter and the context dict as `name`, which then got used as part of a Jinja2 cache key tuple, causing `TypeError: unhashable type: 'dict'`. The fix branches on `STARLETTE_VERSION >= (1,)` to use the new API for Starlette 1.0+ while keeping the old API for older versions. ## Test plan - [x] `tox -e py3.14-starlette-v1.0.0rc1` — 71 passed - [x] `tox -e py3.14-starlette-v0.52.1` — 71 passed (no regression) - [ ] CI passes on all Web 1 jobs 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bb6a5c9 commit d642491

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/integrations/starlette/test_starlette.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ async def _render_template(request):
144144
"request": request,
145145
"msg": "Hello Template World!",
146146
}
147-
return templates.TemplateResponse("trace_meta.html", template_context)
147+
if STARLETTE_VERSION >= (1,):
148+
return templates.TemplateResponse(
149+
request, "trace_meta.html", template_context
150+
)
151+
else:
152+
return templates.TemplateResponse("trace_meta.html", template_context)
148153

149154
all_methods = [
150155
"CONNECT",

0 commit comments

Comments
 (0)