Fix _SameTaskStreamingResponse disconnect test bypassing __init__ (#6627)
* Fix _SameTaskStreamingResponse disconnect test bypassing __init__ test_same_task_response_closes_body_iterator_on_send_disconnect builds the response via __new__ to skip Starlette's __init__, then wires body_iterator, background, and stream_response by hand. It never set _unstarted_cleanup, so the disconnect-before-first-chunk branch of __call__ raised AttributeError instead of ClientDisconnect, failing the Backend CI "Repo tests (CPU)" job on main. Set response._unstarted_cleanup = None in the manual construction, matching the default __init__ assigns. * Shorten the _unstarted_cleanup comment to one line
This commit is contained in:
parent
75166f2043
commit
7a25266203
1 changed files with 2 additions and 0 deletions
|
|
@ -411,6 +411,8 @@ def test_same_task_response_closes_body_iterator_on_send_disconnect():
|
|||
response = m["_SameTaskStreamingResponse"].__new__(m["_SameTaskStreamingResponse"])
|
||||
response.body_iterator = agen
|
||||
response.background = None
|
||||
# __new__ bypasses __init__; __call__'s disconnect branch reads _unstarted_cleanup.
|
||||
response._unstarted_cleanup = None
|
||||
|
||||
async def stream_response(_send):
|
||||
raise OSError("client disconnected")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue