diff options
author | Baptiste Mispelon <bmispelon@gmail.com> | 2014-02-20 19:13:25 +0100 |
---|---|---|
committer | Baptiste Mispelon <bmispelon@gmail.com> | 2014-02-20 19:13:25 +0100 |
commit | 3841feee86cae65165f120db7a5d80ffc76dd520 (patch) | |
tree | 9fc5091ee89041a8fa855bc054e9397df9eb275d /tests/files | |
parent | cb844497d01ddb45603e47891cdf36ae0b006d03 (diff) | |
download | django-3841feee86cae65165f120db7a5d80ffc76dd520.tar.gz |
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.
Diffstat (limited to 'tests/files')
-rw-r--r-- | tests/files/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/files/tests.py b/tests/files/tests.py index f562b5748d..b9f8b5228a 100644 --- a/tests/files/tests.py +++ b/tests/files/tests.py @@ -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): """ |