Refs #33173, Refs #33755 -- Fixed ResourceWarning from unclosed files in ASGI tests.

This commit is contained in:
Carlton Gibson 2022-08-04 09:30:41 +02:00 committed by Carlton Gibson
parent d4db417c8e
commit f476c8847a
1 changed files with 8 additions and 0 deletions

View File

@ -55,6 +55,8 @@ class ASGITest(SimpleTestCase):
response_body = await communicator.receive_output()
self.assertEqual(response_body["type"], "http.response.body")
self.assertEqual(response_body["body"], b"Hello World!")
# Allow response.close() to finish.
await communicator.wait()
async def test_file_response(self):
"""
@ -162,6 +164,8 @@ class ASGITest(SimpleTestCase):
response_body = await communicator.receive_output()
self.assertEqual(response_body["type"], "http.response.body")
self.assertEqual(response_body["body"], b"From Scotland,Wales")
# Allow response.close() to finish
await communicator.wait()
async def test_post_body(self):
application = get_asgi_application()
@ -190,6 +194,8 @@ class ASGITest(SimpleTestCase):
response_body = await communicator.receive_output()
self.assertEqual(response_body["type"], "http.response.body")
self.assertEqual(response_body["body"], b"")
# Allow response.close() to finish
await communicator.wait()
async def test_get_query_string(self):
application = get_asgi_application()
@ -207,6 +213,8 @@ class ASGITest(SimpleTestCase):
response_body = await communicator.receive_output()
self.assertEqual(response_body["type"], "http.response.body")
self.assertEqual(response_body["body"], b"Hello Andrew!")
# Allow response.close() to finish
await communicator.wait()
async def test_disconnect(self):
application = get_asgi_application()