[Python-checkins] cpython (3.3): Correct comments and improve failure reports in test_fileinput (closes #20501).

serhiy.storchaka python-checkins at python.org
Mon Mar 3 20:21:13 CET 2014


http://hg.python.org/cpython/rev/204ef3bca9c8
changeset:   89469:204ef3bca9c8
branch:      3.3
parent:      89458:ca5635efe090
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Mar 03 21:17:17 2014 +0200
summary:
  Correct comments and improve failure reports in test_fileinput (closes #20501).
Thanks Vajrasky Kok and Zachary Ware.

files:
  Lib/test/test_fileinput.py |  11 +++++++----
  1 files changed, 7 insertions(+), 4 deletions(-)


diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -269,9 +269,12 @@
 
         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 @@
         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)
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list