Browse Source

Cover line 438: actually stream _bare_stream in openapi schema test

The test only fetched /openapi.json, leaving the generator body unreachable.
Add a /stream request inside the same TestClient context so the yield
executes, bringing tests/test_sse.py to 100% coverage.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
pull/15191/head
Ben Mosher 2 months ago
parent
commit
f6d54bf36f
  1. 9
      tests/test_sse.py

9
tests/test_sse.py

@ -438,11 +438,14 @@ def test_bare_sse_openapi_has_no_content_schema():
yield ServerSentEvent(comment="ping")
with TestClient(bare_app) as c:
response = c.get("/openapi.json")
assert response.status_code == 200
schema = response.json()
schema_response = c.get("/openapi.json")
stream_response = c.get("/stream")
assert schema_response.status_code == 200
schema = schema_response.json()
sse_schema = schema["paths"]["/stream"]["get"]["responses"]["200"]["content"][
"text/event-stream"
]["itemSchema"]
assert "required" not in sse_schema
assert "contentSchema" not in sse_schema["properties"]["data"]
assert stream_response.status_code == 200
assert ": ping\n" in stream_response.text

Loading…
Cancel
Save