diff Lib/test/test_array.py @ 63128:367529dc34d1

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:41:31 +0000
parents fcfe324663a6
children fa8b57f987c5
line wrap: on
line diff
--- a/Lib/test/test_array.py	Wed Jul 21 15:54:48 2010 +0000
+++ b/Lib/test/test_array.py	Wed Jul 21 16:41:31 2010 +0000
@@ -326,6 +326,17 @@
                 f.close()
             support.unlink(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(support.TESTFN, 'wb')
+        try:
+            self.assertRaises(IOError, a.fromfile, f, len(self.example))
+        finally:
+            f.close()
+            support.unlink(support.TESTFN)
+
     def test_filewrite(self):
         a = array.array(self.typecode, 2*self.example)
         f = open(support.TESTFN, 'wb')