Ticket #27777: 27777-test.diff

File 27777-test.diff, 772 bytes (added by Tim Graham, 8 years ago)
  • tests/file_storage/tests.py

    diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
    index baa6098..2921c7f 100644
    a b class FileFieldStorageTests(TestCase):  
    670670        obj.normal.file.seek(0)
    671671        obj.normal.close()
    672672
     673    def test_filefield_context_manager(self):
     674        obj = Storage.objects.create(normal=SimpleUploadedFile('rewritten.txt', b'content'))
     675        with obj.normal as normal:
     676            self.assertEqual(normal.size, 7)
     677
     678        with obj.normal as normal:
     679            self.assertEqual(normal.size, 7)
     680
    673681    def test_duplicate_filename(self):
    674682        # Multiple files with the same name get _(7 random chars) appended to them.
    675683        objs = [Storage() for i in range(2)]
Back to Top