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
1 changed files with 5 additions and 2 deletions

View File

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