From b45852c2631d4f291fb22ef3348065f2a3c2e5e3 Mon Sep 17 00:00:00 2001 From: Paul J Stevens Date: Fri, 17 Jun 2016 10:30:40 +0200 Subject: [PATCH] Refs #26772 -- Added a test for FileField reopening closed files. Thanks Simon Charette for review. --- tests/file_storage/tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index 44da2a547f7..337cc749ae3 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -733,6 +733,14 @@ class FileFieldStorageTests(TestCase): self.assertEqual(list(obj.normal.chunks(chunk_size=2)), [b"co", b"nt", b"en", b"t"]) obj.normal.close() + def test_filefield_reopen(self): + obj = Storage.objects.create(normal=SimpleUploadedFile('reopen.txt', b'content')) + with obj.normal as normal: + normal.open() + obj.normal.open() + obj.normal.file.seek(0) + obj.normal.close() + def test_duplicate_filename(self): # Multiple files with the same name get _(7 random chars) appended to them. objs = [Storage() for i in range(2)]