diff options
author | Chillar Anand <anand21nanda@gmail.com> | 2017-01-27 00:24:16 +0530 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-01-26 13:54:16 -0500 |
commit | 6478e07a62ce968f33e71a345e561bce36923f8e (patch) | |
tree | ef8a1c8cdfbd03fe51d22a346871eab156ddc275 /tests/file_uploads | |
parent | fee42fd99ee470528858c2ccb3621135c30ec262 (diff) | |
download | django-6478e07a62ce968f33e71a345e561bce36923f8e.tar.gz |
Refs #23919 -- Replaced tempfile.mkdtemp() with TemporaryDirectory() context manager.
Diffstat (limited to 'tests/file_uploads')
-rw-r--r-- | tests/file_uploads/tests.py | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py index 51e6937598..343d3f2de6 100644 --- a/tests/file_uploads/tests.py +++ b/tests/file_uploads/tests.py @@ -103,21 +103,13 @@ class FileUploadTests(TestCase): self._test_base64_upload("Big data" * 68000, encode=base64.encodebytes) def test_unicode_file_name(self): - tdir = sys_tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, tdir, True) - - # This file contains Chinese symbols and an accented char in the name. - with open(os.path.join(tdir, UNICODE_FILENAME), 'w+b') as file1: - file1.write(b'b' * (2 ** 10)) - file1.seek(0) - - post_data = { - 'file_unicode': file1, - } - - response = self.client.post('/unicode_name/', post_data) - - self.assertEqual(response.status_code, 200) + with sys_tempfile.TemporaryDirectory() as temp_dir: + # This file contains Chinese symbols and an accented char in the name. + with open(os.path.join(temp_dir, UNICODE_FILENAME), 'w+b') as file1: + file1.write(b'b' * (2 ** 10)) + file1.seek(0) + response = self.client.post('/unicode_name/', {'file_unicode': file1}) + self.assertEqual(response.status_code, 200) def test_unicode_file_name_rfc2231(self): """ |