diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-11-05 23:20:23 -0800 |
---|---|---|
committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-11-06 08:20:23 +0100 |
commit | 1c4c68dfed289093aaa2baf86bac7826c91e59ce (patch) | |
tree | c3faa5b1da4a583299dc14038dfd9bf1df7484df /tests/files | |
parent | 92e5abd7a3dbbea88b3d43d5790f94e276bc6dff (diff) | |
download | django-1c4c68dfed289093aaa2baf86bac7826c91e59ce.tar.gz |
Refs #29983 -- Added test for FILE_UPLOAD_TEMP_DIR pathlib support.
Diffstat (limited to 'tests/files')
-rw-r--r-- | tests/files/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/files/tests.py b/tests/files/tests.py index 1c005dde57..047c8935b8 100644 --- a/tests/files/tests.py +++ b/tests/files/tests.py @@ -5,6 +5,7 @@ import struct import tempfile import unittest from io import BytesIO, StringIO, TextIOWrapper +from pathlib import Path from unittest import mock from django.core.files import File @@ -15,6 +16,7 @@ from django.core.files.uploadedfile import ( InMemoryUploadedFile, SimpleUploadedFile, TemporaryUploadedFile, UploadedFile, ) +from django.test import override_settings try: from PIL import Image @@ -231,6 +233,12 @@ class TemporaryUploadedFileTests(unittest.TestCase): with TemporaryUploadedFile('test.txt', 'text/plain', 1, 'utf8') as temp_file: self.assertTrue(temp_file.file.name.endswith('.upload.txt')) + def test_file_upload_temp_dir_pathlib(self): + with tempfile.TemporaryDirectory() as tmp_dir: + with override_settings(FILE_UPLOAD_TEMP_DIR=Path(tmp_dir)): + with TemporaryUploadedFile('test.txt', 'text/plain', 1, 'utf-8') as temp_file: + self.assertTrue(os.path.exists(temp_file.file.name)) + class DimensionClosingBug(unittest.TestCase): """ |