mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #22107 -- Fixed django.core.files.File object iteration.
Due to a mixup between text and bytes, iteration over a File instance was broken under Python 3. Thanks to trac user pdewacht for the report and patch.
This commit is contained in:
@@ -64,6 +64,14 @@ class FileTests(unittest.TestCase):
|
||||
self.assertFalse(hasattr(file, 'mode'))
|
||||
gzip.GzipFile(fileobj=file)
|
||||
|
||||
def test_file_iteration(self):
|
||||
"""
|
||||
File objects should yield lines when iterated over.
|
||||
Refs #22107.
|
||||
"""
|
||||
file = File(BytesIO(b'one\ntwo\nthree'))
|
||||
self.assertEqual(list(file), [b'one\n', b'two\n', b'three'])
|
||||
|
||||
|
||||
class NoNameFileTestCase(unittest.TestCase):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user