[1.10.x] Refs #26772 -- Added a test for FileField reopening closed files.

Thanks Simon Charette for review.

Backport of b45852c263 from master
This commit is contained in:
Paul J Stevens 2016-06-17 10:30:40 +02:00 committed by Tim Graham
parent e2b266fdf7
commit d3b9c49919
1 changed files with 8 additions and 0 deletions

View File

@ -735,6 +735,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)]