Skip to content

Commit 153244b

Browse files
authored
Revert 31791 (#31931)
1 parent 8f49265 commit 153244b

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

pandas/tests/io/test_common.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,24 @@ def test_read_non_existant(self, reader, module, error_class, fn_ext):
141141
pytest.importorskip(module)
142142

143143
path = os.path.join(HERE, "data", "does_not_exist." + fn_ext)
144-
with tm.external_error_raised(error_class):
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}"
157+
158+
with pytest.raises(
159+
error_class,
160+
match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})",
161+
):
145162
reader(path)
146163

147164
@pytest.mark.parametrize(
@@ -167,7 +184,24 @@ def test_read_expands_user_home_dir(
167184
path = os.path.join("~", "does_not_exist." + fn_ext)
168185
monkeypatch.setattr(icom, "_expand_user", lambda x: os.path.join("foo", x))
169186

170-
with tm.external_error_raised(error_class):
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}"
200+
201+
with pytest.raises(
202+
error_class,
203+
match=fr"({msg1}|{msg2}|{msg3}|{msg4}|{msg5}|{msg6}|{msg7}|{msg8})",
204+
):
171205
reader(path)
172206

173207
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)