Skip to content

Commit f476c88

Browse files
committed
Refs #33173, Refs #33755 -- Fixed ResourceWarning from unclosed files in ASGI tests.
1 parent d4db417 commit f476c88

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/asgi/tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ async def test_get_asgi_application(self):
5555
response_body = await communicator.receive_output()
5656
self.assertEqual(response_body["type"], "http.response.body")
5757
self.assertEqual(response_body["body"], b"Hello World!")
58+
# Allow response.close() to finish.
59+
await communicator.wait()
5860

5961
async def test_file_response(self):
6062
"""
@@ -162,6 +164,8 @@ async def test_headers(self):
162164
response_body = await communicator.receive_output()
163165
self.assertEqual(response_body["type"], "http.response.body")
164166
self.assertEqual(response_body["body"], b"From Scotland,Wales")
167+
# Allow response.close() to finish
168+
await communicator.wait()
165169

166170
async def test_post_body(self):
167171
application = get_asgi_application()
@@ -190,6 +194,8 @@ async def test_untouched_request_body_gets_closed(self):
190194
response_body = await communicator.receive_output()
191195
self.assertEqual(response_body["type"], "http.response.body")
192196
self.assertEqual(response_body["body"], b"")
197+
# Allow response.close() to finish
198+
await communicator.wait()
193199

194200
async def test_get_query_string(self):
195201
application = get_asgi_application()
@@ -207,6 +213,8 @@ async def test_get_query_string(self):
207213
response_body = await communicator.receive_output()
208214
self.assertEqual(response_body["type"], "http.response.body")
209215
self.assertEqual(response_body["body"], b"Hello Andrew!")
216+
# Allow response.close() to finish
217+
await communicator.wait()
210218

211219
async def test_disconnect(self):
212220
application = get_asgi_application()

0 commit comments

Comments
 (0)