@@ -107,6 +107,26 @@ def test_iterator(self):
107107 tm .assert_frame_equal (first , expected .iloc [[0 ]])
108108 tm .assert_frame_equal (concat (it ), expected .iloc [1 :])
109109
110+ @pytest .mark .parametrize ('reader, module, error_class, fn_ext' , [
111+ (pd .read_csv , 'os' , pd .compat .FileNotFoundError , 'csv' ),
112+ (pd .read_table , 'os' , pd .compat .FileNotFoundError , 'csv' ),
113+ (pd .read_fwf , 'os' , pd .compat .FileNotFoundError , 'txt' ),
114+ (pd .read_excel , 'xlrd' , ValueError , 'xlsx' ),
115+ (pd .read_feather , 'feather' , ValueError , 'feather' ),
116+ (pd .read_hdf , 'tables' , ValueError , 'h5' ),
117+ (pd .read_stata , 'os' , pd .compat .FileNotFoundError , 'dta' ),
118+ (pd .read_sas , 'os' , pd .compat .FileNotFoundError , 'sas7bdat' ),
119+ (pd .read_json , 'os' , ValueError , 'json' ),
120+ (pd .read_msgpack , 'os' , ValueError , 'mp' ),
121+ (pd .read_pickle , 'os' , pd .compat .FileNotFoundError , 'pickle' ),
122+ ])
123+ def test_read_non_existant (self , reader , module , error_class , fn_ext ):
124+ pytest .importorskip (module )
125+
126+ path = os .path .join (HERE , 'data' , 'does_not_exist.' + fn_ext )
127+ with pytest .raises (error_class ):
128+ reader (path )
129+
110130 @pytest .mark .parametrize ('reader, module, path' , [
111131 (pd .read_csv , 'os' , os .path .join (HERE , 'data' , 'iris.csv' )),
112132 (pd .read_table , 'os' , os .path .join (HERE , 'data' , 'iris.csv' )),
0 commit comments