@@ -165,16 +165,14 @@ def test_array_from_file():
165
165
arr = array_from_file ((0 ,), np .dtype ('f8' ), BytesIO ())
166
166
assert len (arr ) == 0
167
167
# Check error from small file
168
- with pytest .raises (IOError ):
168
+ with pytest .raises (OSError ):
169
169
array_from_file (shape , dtype , BytesIO ())
170
170
# check on real file
171
171
fd , fname = tempfile .mkstemp ()
172
172
with InTemporaryDirectory ():
173
173
open (fname , 'wb' ).write (b'1' )
174
174
in_buf = open (fname , 'rb' )
175
- # For windows this will raise a WindowsError from mmap, Unices
176
- # appear to raise an IOError
177
- with pytest .raises (Exception ):
175
+ with pytest .raises (OSError ):
178
176
array_from_file (shape , dtype , in_buf )
179
177
del in_buf
180
178
@@ -983,7 +981,7 @@ def test_seek_tell():
983
981
assert fobj .tell () == 10
984
982
seek_tell (fobj , 10 )
985
983
assert fobj .tell () == 10
986
- with pytest .raises (IOError ):
984
+ with pytest .raises (OSError ):
987
985
seek_tell (fobj , 5 )
988
986
# Make sure read seeks don't affect file
989
987
with ImageOpener (in_file , 'rb' ) as fobj :
@@ -1003,10 +1001,10 @@ def test_seek_tell_logic():
1003
1001
class BabyBio (BytesIO ):
1004
1002
1005
1003
def seek (self , * args ):
1006
- raise IOError ()
1004
+ raise OSError ()
1007
1005
bio = BabyBio ()
1008
1006
# Fresh fileobj, position 0, can't seek - error
1009
- with pytest .raises (IOError ):
1007
+ with pytest .raises (OSError ):
1010
1008
bio .seek (10 )
1011
1009
# Put fileobj in correct position by writing
1012
1010
ZEROB = b'\x00 '
@@ -1015,7 +1013,7 @@ def seek(self, *args):
1015
1013
assert bio .tell () == 10
1016
1014
assert bio .getvalue () == ZEROB * 10
1017
1015
# Try write zeros to get to new position
1018
- with pytest .raises (IOError ):
1016
+ with pytest .raises (OSError ):
1019
1017
bio .seek (20 )
1020
1018
seek_tell (bio , 20 , write0 = True )
1021
1019
assert bio .getvalue () == ZEROB * 20
@@ -1206,7 +1204,7 @@ def read(self, n_bytes):
1206
1204
return b''
1207
1205
try :
1208
1206
array_from_file (shape , np .int8 , NoStringIO ())
1209
- except IOError as err :
1207
+ except OSError as err :
1210
1208
message = str (err )
1211
1209
assert message == ("Expected 11390625000000000000 bytes, got 0 "
1212
1210
"bytes from object\n - could the file be damaged?" )
0 commit comments