summaryrefslogtreecommitdiff
path: root/tests/files/tests.py
diff options
context:
space:
mode:
authorHugo Osvaldo Barrera <hugo@barrera.io>2016-05-27 14:54:26 -0300
committerTim Graham <timograham@gmail.com>2016-06-14 09:28:08 -0400
commit1b407050dd53e56686fdd3e168f8cac4f9be8306 (patch)
treeaeb5c854bdfe996774f344e2083d6f3b4e2d085c /tests/files/tests.py
parentfa654da6130df80239e181c432595442e688ee8b (diff)
Fixed #26644 -- Allowed wrapping NamedTemporaryFile with File.
914c72be2abb1c6dd860cb9279beaa66409ae1b2 introduced a regression that causes saving a NamedTemporaryFile in a FileField to raise a SuspiciousFileOperation. To remedy this, if a File has an absolute path as a filename, use only the basename as the filename.
Diffstat (limited to 'tests/files/tests.py')
-rw-r--r--tests/files/tests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/files/tests.py b/tests/files/tests.py
index d22020cb8c..12207fee99 100644
--- a/tests/files/tests.py
+++ b/tests/files/tests.py
@@ -26,6 +26,12 @@ else:
class FileTests(unittest.TestCase):
+
+ def test_file_truncates_namedtemporaryfile_name(self):
+ named_file = NamedTemporaryFile()
+ f = File(named_file)
+ self.assertEqual(f.name, os.path.basename(named_file.name))
+
def test_unicode_uploadedfile_name(self):
uf = UploadedFile(name='¿Cómo?', content_type='text')
self.assertIs(type(repr(uf)), str)