]> granicus.if.org Git - python/commitdiff
Merged revisions 83030 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 21 Jul 2010 16:53:04 +0000 (16:53 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 21 Jul 2010 16:53:04 +0000 (16:53 +0000)
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)
........

Lib/test/test_array.py

index dd01574174a46a030d96846a6df4927ce083d456..4cac68bb1b8caa76f64f9b42ec795eb24fe1c8ff 100755 (executable)
@@ -182,6 +182,17 @@ class BaseTest(unittest.TestCase):
                 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_tofromlist(self):
         a = array.array(self.typecode, 2*self.example)
         b = array.array(self.typecode)