@@ -125,6 +125,26 @@ def test_iterator(self):
125125 tm .assert_frame_equal (first , expected .iloc [[0 ]])
126126 tm .assert_frame_equal (concat (it ), expected .iloc [1 :])
127127
128+ @pytest .mark .parametrize ('reader, module, error_class, fn_ext' , [
129+ (pd .read_csv , 'os' , pd .compat .FileNotFoundError , 'csv' ),
130+ (pd .read_table , 'os' , pd .compat .FileNotFoundError , 'csv' ),
131+ (pd .read_fwf , 'os' , pd .compat .FileNotFoundError , 'txt' ),
132+ (pd .read_excel , 'xlrd' , ValueError , 'xlsx' ),
133+ (pd .read_feather , 'feather' , ValueError , 'feather' ),
134+ (pd .read_hdf , 'tables' , ValueError , 'h5' ),
135+ (pd .read_stata , 'os' , pd .compat .FileNotFoundError , 'dta' ),
136+ (pd .read_sas , 'os' , pd .compat .FileNotFoundError , 'sas7bdat' ),
137+ (pd .read_json , 'os' , ValueError , 'json' ),
138+ (pd .read_msgpack , 'os' , ValueError , 'mp' ),
139+ (pd .read_pickle , 'os' , pd .compat .FileNotFoundError , 'pickle' ),
140+ ])
141+ def test_read_non_existant (self , reader , module , error_class , fn_ext ):
142+ pytest .importorskip (module )
143+
144+ path = os .path .join (HERE , 'data' , 'does_not_exist.' + fn_ext )
145+ with pytest .raises (error_class ):
146+ reader (path )
147+
128148 @pytest .mark .parametrize ('reader, module, path' , [
129149 (pd .read_csv , 'os' , os .path .join (HERE , 'data' , 'iris.csv' )),
130150 (pd .read_table , 'os' , os .path .join (HERE , 'data' , 'iris.csv' )),
0 commit comments