@@ -141,24 +141,7 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext):
141
141
pytest .importorskip (module )
142
142
143
143
path = os .path .join (HERE , "data" , "does_not_exist." + fn_ext )
144
- msg1 = r"File (b')?.+does_not_exist\.{}'? does not exist" .format (fn_ext )
145
- msg2 = fr"\[Errno 2\] No such file or directory: '.+does_not_exist\.{ fn_ext } '"
146
- msg3 = "Expected object or value"
147
- msg4 = "path_or_buf needs to be a string file path or file-like"
148
- msg5 = (
149
- fr"\[Errno 2\] File .+does_not_exist\.{ fn_ext } does not exist: "
150
- fr"'.+does_not_exist\.{ fn_ext } '"
151
- )
152
- msg6 = fr"\[Errno 2\] 没有那个文件或目录: '.+does_not_exist\.{ fn_ext } '"
153
- msg7 = (
154
- fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{ fn_ext } '"
155
- )
156
- msg8 = fr"Failed to open local file.+does_not_exist\.{ fn_ext } .?, error: .*"
157
-
158
- with pytest .raises (
159
- error_class ,
160
- match = fr"({ msg1 } |{ msg2 } |{ msg3 } |{ msg4 } |{ msg5 } |{ msg6 } |{ msg7 } |{ msg8 } )" ,
161
- ):
144
+ with tm .external_error_raised (error_class ):
162
145
reader (path )
163
146
164
147
@pytest .mark .parametrize (
@@ -184,24 +167,7 @@ def test_read_expands_user_home_dir(
184
167
path = os .path .join ("~" , "does_not_exist." + fn_ext )
185
168
monkeypatch .setattr (icom , "_expand_user" , lambda x : os .path .join ("foo" , x ))
186
169
187
- msg1 = fr"File (b')?.+does_not_exist\.{ fn_ext } '? does not exist"
188
- msg2 = fr"\[Errno 2\] No such file or directory: '.+does_not_exist\.{ fn_ext } '"
189
- msg3 = "Unexpected character found when decoding 'false'"
190
- msg4 = "path_or_buf needs to be a string file path or file-like"
191
- msg5 = (
192
- fr"\[Errno 2\] File .+does_not_exist\.{ fn_ext } does not exist: "
193
- fr"'.+does_not_exist\.{ fn_ext } '"
194
- )
195
- msg6 = fr"\[Errno 2\] 没有那个文件或目录: '.+does_not_exist\.{ fn_ext } '"
196
- msg7 = (
197
- fr"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{ fn_ext } '"
198
- )
199
- msg8 = fr"Failed to open local file.+does_not_exist\.{ fn_ext } .?, error: .*"
200
-
201
- with pytest .raises (
202
- error_class ,
203
- match = fr"({ msg1 } |{ msg2 } |{ msg3 } |{ msg4 } |{ msg5 } |{ msg6 } |{ msg7 } |{ msg8 } )" ,
204
- ):
170
+ with tm .external_error_raised (error_class ):
205
171
reader (path )
206
172
207
173
@pytest .mark .parametrize (
0 commit comments