diff Lib/test/test_array.py @ 63129:e5cdb12768cb 2.7

Merged revisions 83030 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83030 | antoine.pitrou | 2010-07-21 18:41:31 +0200 (mer., 21 juil. 2010) | 5 lines Issue #5395: check that array.fromfile() re-raises an IOError instead of replacing it with EOFError. (this is only an added test, but 2.x will get a fix too) ........
author Antoine Pitrou <solipsis@pitrou.net>
date Wed, 21 Jul 2010 16:47:28 +0000
parents c8c840162804
children 614c84670c63
line wrap: on
line diff
--- a/Lib/test/test_array.py	Wed Jul 21 15:56:03 2010 +0000
+++ b/Lib/test/test_array.py	Wed Jul 21 16:47:28 2010 +0000
@@ -188,6 +188,17 @@
                 f.close()
             test_support.unlink(test_support.TESTFN)
 
+    def test_fromfile_ioerror(self):
+        # Issue #5395: Check if fromfile raises a proper IOError
+        # instead of EOFError.
+        a = array.array(self.typecode)
+        f = open(test_support.TESTFN, 'wb')
+        try:
+            self.assertRaises(IOError, a.fromfile, f, len(self.example))
+        finally:
+            f.close()
+            test_support.unlink(test_support.TESTFN)
+
     def test_filewrite(self):
         a = array.array(self.typecode, 2*self.example)
         f = open(test_support.TESTFN, 'wb')