Skip to content

Commit 682ea5f

Browse files
Correct comments and improve failure reports in test_fileinput (closes python#20501).
Thanks Vajrasky Kok and Zachary Ware.
1 parent c186b23 commit 682ea5f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Lib/test/test_fileinput.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,12 @@ def test_readline(self):
269269

270270
with FileInput(files=TESTFN,
271271
openhook=hook_encoded('ascii'), bufsize=8) as fi:
272-
self.assertEqual(fi.readline(), 'A\n')
273-
self.assertEqual(fi.readline(), 'B\n')
274-
self.assertEqual(fi.readline(), 'C\n')
272+
try:
273+
self.assertEqual(fi.readline(), 'A\n')
274+
self.assertEqual(fi.readline(), 'B\n')
275+
self.assertEqual(fi.readline(), 'C\n')
276+
except UnicodeDecodeError:
277+
self.fail('Read to end of file')
275278
with self.assertRaises(UnicodeDecodeError):
276279
# Read to the end of file.
277280
list(fi)
@@ -854,8 +857,8 @@ def test(self):
854857
self.assertFalse(kwargs)
855858

856859
def test_modes(self):
857-
# Unlikely UTF-7 is locale encoding
858860
with open(TESTFN, 'wb') as f:
861+
# UTF-7 is a convenient, seldom used encoding
859862
f.write(b'A\nB\r\nC\rD+IKw-')
860863
self.addCleanup(safe_unlink, TESTFN)
861864

0 commit comments

Comments
 (0)