From 7b0ed458d960f1b0bf5c46a74b2fef0e0def71b8 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 4 Aug 2022 10:14:23 +0200 Subject: [PATCH] [4.1.x] Refs #33173, Refs #33755 -- Fixed ResourceWarning from unclosed files in ASGI tests. Backport of f476c8847a0bf1a4e20becfb3dc66f4da0dbf579 from main --- tests/asgi/tests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/asgi/tests.py b/tests/asgi/tests.py index cfee11802c..e93e1fdc8c 100644 --- a/tests/asgi/tests.py +++ b/tests/asgi/tests.py @@ -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() @@ -191,6 +195,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()