From 8db6a6c0a1c73bf08e71e00d4ab8c4af3c5f0cb8 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 12 Dec 2016 09:41:38 -0800 Subject: [PATCH] Refs #27184 -- Fixed unclosed file ResourceWarning in test_client test. --- tests/test_client/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index a499ee7fce..8b834e02e0 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -717,8 +717,8 @@ class ClientTest(TestCase): self.client.get('/nesting_exception_view/') def test_uploading_temp_file(self): - test_file = tempfile.TemporaryFile() - response = self.client.post('/upload_view/', data={'temp_file': test_file}) + with tempfile.TemporaryFile() as test_file: + response = self.client.post('/upload_view/', data={'temp_file': test_file}) self.assertEqual(response.content, b'temp_file') def test_uploading_named_temp_file(self):