summaryrefslogtreecommitdiff
path: root/tests/files
diff options
context:
space:
mode:
Diffstat (limited to 'tests/files')
-rw-r--r--tests/files/tests.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/files/tests.py b/tests/files/tests.py
index daf5a30e9d..2766ed1630 100644
--- a/tests/files/tests.py
+++ b/tests/files/tests.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
+from io import BytesIO
import os
import gzip
import shutil
@@ -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):