Skip to content

Commit 1d3313a

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
Avoid test failures on Hurd
Allow multiprocessing to be unavailable Accept any errno not just 2 for (intentionally) nonexistent files (Hurd appears to use 2**30+2) Author: Rebecca N. Palmer <[email protected]> Forwarded: no Gbp-Pq: Name hurd_compat.patch
1 parent 0c89e2a commit 1d3313a

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

pandas/tests/io/parser/common/test_file_buffer_url.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_nonexistent_path(all_parsers):
100100
parser = all_parsers
101101
path = f"{uuid.uuid4()}.csv"
102102

103-
msg = r"\[Errno 2\]"
103+
msg = r"\[Errno 2\]|\[Errno [0-9]+\] No such file or directory"
104104
with pytest.raises(FileNotFoundError, match=msg) as e:
105105
parser.read_csv(path)
106106
assert path == e.value.filename
@@ -111,7 +111,7 @@ def test_no_permission(all_parsers):
111111
# GH 23784
112112
parser = all_parsers
113113

114-
msg = r"\[Errno 13\]"
114+
msg = r"\[Errno 13\]|\[Errno [0-9]+\] Permission denied"
115115
with tm.ensure_clean() as path:
116116
os.chmod(path, 0) # make file unreadable
117117

pandas/tests/io/parser/common/test_float.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_too_many_exponent_digits(all_parsers_all_precisions, exp, request):
6767
data = f"data\n10E{exp}"
6868
result = parser.read_csv(StringIO(data), float_precision=precision)
6969
if precision == "round_trip":
70-
if exp == 999999999999999999 and is_platform_linux():
70+
if exp == 999999999999999999:
7171
mark = pytest.mark.xfail(reason="GH38794, on Linux gives object result")
7272
request.applymarker(mark)
7373

pandas/tests/io/parser/test_multi_thread.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
"""
55
from contextlib import ExitStack
66
from io import BytesIO
7-
from multiprocessing.pool import ThreadPool
7+
import pytest
8+
try:
9+
from multiprocessing.pool import ThreadPool
10+
with ThreadPool():
11+
pass
12+
except ImportError:
13+
pytest.skip("multiprocessing not available",allow_module_level=True)
814

915
import numpy as np
1016
import pytest

pandas/tests/io/test_common.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,16 @@ def test_read_non_existent(self, reader, module, error_class, fn_ext):
200200

201201
path = os.path.join(HERE, "data", "does_not_exist." + fn_ext)
202202
msg1 = rf"File (b')?.+does_not_exist\.{fn_ext}'? does not exist"
203-
msg2 = rf"\[Errno 2\] No such file or directory: '.+does_not_exist\.{fn_ext}'"
203+
msg2 = rf"\[Errno [0-9]+\] No such file or directory: '.+does_not_exist\.{fn_ext}'"
204204
msg3 = "Expected object or value"
205205
msg4 = "path_or_buf needs to be a string file path or file-like"
206206
msg5 = (
207-
rf"\[Errno 2\] File .+does_not_exist\.{fn_ext} does not exist: "
207+
rf"\[Errno [0-9]+\] File .+does_not_exist\.{fn_ext} does not exist: "
208208
rf"'.+does_not_exist\.{fn_ext}'"
209209
)
210-
msg6 = rf"\[Errno 2\] 没有那个文件或目录: '.+does_not_exist\.{fn_ext}'"
210+
msg6 = rf"\[Errno [0-9]+\] 没有那个文件或目录: '.+does_not_exist\.{fn_ext}'"
211211
msg7 = (
212-
rf"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'"
212+
rf"\[Errno [0-9]+\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'"
213213
)
214214
msg8 = rf"Failed to open local file.+does_not_exist\.{fn_ext}"
215215

@@ -270,16 +270,16 @@ def test_read_expands_user_home_dir(
270270
monkeypatch.setattr(icom, "_expand_user", lambda x: os.path.join("foo", x))
271271

272272
msg1 = rf"File (b')?.+does_not_exist\.{fn_ext}'? does not exist"
273-
msg2 = rf"\[Errno 2\] No such file or directory: '.+does_not_exist\.{fn_ext}'"
273+
msg2 = rf"\[Errno [0-9]+\] No such file or directory: '.+does_not_exist\.{fn_ext}'"
274274
msg3 = "Unexpected character found when decoding 'false'"
275275
msg4 = "path_or_buf needs to be a string file path or file-like"
276276
msg5 = (
277-
rf"\[Errno 2\] File .+does_not_exist\.{fn_ext} does not exist: "
277+
rf"\[Errno [0-9]+\] File .+does_not_exist\.{fn_ext} does not exist: "
278278
rf"'.+does_not_exist\.{fn_ext}'"
279279
)
280-
msg6 = rf"\[Errno 2\] 没有那个文件或目录: '.+does_not_exist\.{fn_ext}'"
280+
msg6 = rf"\[Errno [0-9]+\] 没有那个文件或目录: '.+does_not_exist\.{fn_ext}'"
281281
msg7 = (
282-
rf"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'"
282+
rf"\[Errno [0-9]+\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'"
283283
)
284284
msg8 = rf"Failed to open local file.+does_not_exist\.{fn_ext}"
285285

@@ -607,7 +607,7 @@ def test_bad_encdoing_errors():
607607

608608
def test_errno_attribute():
609609
# GH 13872
610-
with pytest.raises(FileNotFoundError, match="\\[Errno 2\\]") as err:
610+
with pytest.raises(FileNotFoundError, match="\\[Errno [0-9]+\\]") as err:
611611
pd.read_csv("doesnt_exist")
612612
assert err.errno == errno.ENOENT
613613

pandas/tests/test_downstream.py

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ def df():
3131

3232

3333
def test_dask(df):
34+
try:
35+
from multiprocessing.pool import ThreadPool
36+
with ThreadPool():
37+
pass
38+
except ImportError:
39+
pytest.skip("multiprocessing not available")
3440
# dask sets "compute.use_numexpr" to False, so catch the current value
3541
# and ensure to reset it afterwards to avoid impacting other tests
3642
olduse = pd.get_option("compute.use_numexpr")

0 commit comments

Comments
 (0)