diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-03-03 19:19:19 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-03-03 19:19:19 (GMT) |
commit | cd9028ca692fdc3e1cb3a428bfa558bd8bcfbc1b (patch) | |
tree | 69193525f341c9548870182123a5809430450c28 /Lib/test/test_fileinput.py | |
parent | f70200e5a90b83348f331d2a3b91db24d2c8365e (diff) | |
parent | 682ea5f70e5450ffd5a50ef7f39d65c2faeb6b63 (diff) | |
download | cpython-cd9028ca692fdc3e1cb3a428bfa558bd8bcfbc1b.zip cpython-cd9028ca692fdc3e1cb3a428bfa558bd8bcfbc1b.tar.gz cpython-cd9028ca692fdc3e1cb3a428bfa558bd8bcfbc1b.tar.bz2 |
Correct comments and improve failure reports in test_fileinput (closes #20501).
Thanks Vajrasky Kok and Zachary Ware.
Diffstat (limited to 'Lib/test/test_fileinput.py')
-rw-r--r-- | 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 index a537bc8..eba55c9 100644 --- a/Lib/test/test_fileinput.py +++ b/Lib/test/test_fileinput.py @@ -271,9 +271,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) @@ -856,8 +859,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) |