]> granicus.if.org Git - python/commitdiff
Correct comments and improve failure reports in test_fileinput (closes #20501).
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 3 Mar 2014 19:17:17 +0000 (21:17 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 3 Mar 2014 19:17:17 +0000 (21:17 +0200)
Thanks Vajrasky Kok and Zachary Ware.

Lib/test/test_fileinput.py

index a7624d3c3d97bab638c1245ad9725f193dad676e..b9523cc333f287f13280088f5da626a174bdef40 100644 (file)
@@ -269,9 +269,12 @@ class FileInputTests(unittest.TestCase):
 
         with FileInput(files=TESTFN,
                        openhook=hook_encoded('ascii'), bufsize=8) as fi:
-            self.assertEqual(fi.readline(), 'A\n')
-            self.assertEqual(fi.readline(), 'B\n')
-            self.assertEqual(fi.readline(), 'C\n')
+            try:
+                self.assertEqual(fi.readline(), 'A\n')
+                self.assertEqual(fi.readline(), 'B\n')
+                self.assertEqual(fi.readline(), 'C\n')
+            except UnicodeDecodeError:
+                self.fail('Read to end of file')
             with self.assertRaises(UnicodeDecodeError):
                 # Read to the end of file.
                 list(fi)
@@ -854,8 +857,8 @@ class Test_hook_encoded(unittest.TestCase):
         self.assertFalse(kwargs)
 
     def test_modes(self):
-        # Unlikely UTF-7 is locale encoding
         with open(TESTFN, 'wb') as f:
+            # UTF-7 is a convenient, seldom used encoding
             f.write(b'A\nB\r\nC\rD+IKw-')
         self.addCleanup(safe_unlink, TESTFN)