1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed ResourceWarning in test_client.tests.ClientTest.test_uploading_named_temp_file().

This commit is contained in:
Mariusz Felisiak 2021-06-24 11:47:29 +02:00 committed by GitHub
parent fff4870bfa
commit 27e156fa31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -894,8 +894,11 @@ class ClientTest(TestCase):
self.assertEqual(response.content, b'temp_file')
def test_uploading_named_temp_file(self):
test_file = tempfile.NamedTemporaryFile()
response = self.client.post('/upload_view/', data={'named_temp_file': test_file})
with tempfile.NamedTemporaryFile() as test_file:
response = self.client.post(
'/upload_view/',
data={'named_temp_file': test_file},
)
self.assertEqual(response.content, b'named_temp_file')