Loading django/core/files/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ class File(FileProxyMixin): # If this is the end of a line, yield # otherwise, wait for the next round if line[-1] in ('\n', '\r'): if line[-1:] in (b'\n', b'\r'): yield line else: buffer_ = line Loading tests/files/tests.py +9 −0 Original line number Diff line number Diff line from __future__ import absolute_import from io import BytesIO import os import gzip import shutil Loading Loading @@ -164,6 +165,14 @@ class FileTests(unittest.TestCase): self.assertFalse(hasattr(file, 'mode')) g = 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 FileMoveSafeTests(unittest.TestCase): def test_file_move_overwrite(self): Loading Loading
django/core/files/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ class File(FileProxyMixin): # If this is the end of a line, yield # otherwise, wait for the next round if line[-1] in ('\n', '\r'): if line[-1:] in (b'\n', b'\r'): yield line else: buffer_ = line Loading
tests/files/tests.py +9 −0 Original line number Diff line number Diff line from __future__ import absolute_import from io import BytesIO import os import gzip import shutil Loading Loading @@ -164,6 +165,14 @@ class FileTests(unittest.TestCase): self.assertFalse(hasattr(file, 'mode')) g = 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 FileMoveSafeTests(unittest.TestCase): def test_file_move_overwrite(self): Loading