1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #29188 -- Fixed ContentFile.size after a write().

This commit is contained in:
Alex Stovbur
2018-03-07 23:20:25 +02:00
committed by Tim Graham
parent 277ed07209
commit 2d9ec4d735
2 changed files with 14 additions and 0 deletions

View File

@@ -206,6 +206,16 @@ class ContentFileTestCase(unittest.TestCase):
with file.open() as f:
self.assertEqual(f.read(), b'content')
def test_size_changing_after_writing(self):
"""ContentFile.size changes after a write()."""
f = ContentFile('')
self.assertEqual(f.size, 0)
f.write('Test ')
f.write('string')
self.assertEqual(f.size, 11)
with f.open() as fh:
self.assertEqual(fh.read(), 'Test string')
class InMemoryUploadedFileTests(unittest.TestCase):
def test_open_resets_file_to_start_and_returns_context_manager(self):