Skip to content

Commit 1736111

Browse files
Debian Science Teamraspbian-autopush
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 68cd126 commit 1736111

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_nonexistent_path(all_parsers):
8383
parser = all_parsers
8484
path = f"{uuid.uuid4()}.csv"
8585

86-
msg = r"\[Errno 2\]"
86+
msg = r"\[Errno 2\]|\[Errno [0-9]+\] No such file or directory"
8787
with pytest.raises(FileNotFoundError, match=msg) as e:
8888
parser.read_csv(path)
8989
assert path == e.value.filename
@@ -94,7 +94,7 @@ def test_no_permission(all_parsers):
9494
# GH 23784
9595
parser = all_parsers
9696

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_too_many_exponent_digits(all_parsers_all_precisions, exp, request):
5353
data = f"data\n10E{exp}"
5454
result = parser.read_csv(StringIO(data), float_precision=precision)
5555
if precision == "round_trip":
56-
if exp == 999999999999999999 and is_platform_linux():
56+
if exp == 999999999999999999:
5757
mark = pytest.mark.xfail(reason="GH38794, on Linux gives object result")
5858
request.node.add_marker(mark)
5959

pandas/tests/io/parser/test_multi_thread.py

Lines changed: 7 additions & 1 deletion
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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,16 @@ def test_read_non_existent(self, reader, module, error_class, fn_ext):
195195

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

@@ -265,16 +265,16 @@ def test_read_expands_user_home_dir(
265265
monkeypatch.setattr(icom, "_expand_user", lambda x: os.path.join("foo", x))
266266

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

@@ -578,7 +578,7 @@ def test_bad_encdoing_errors():
578578

579579
def test_errno_attribute():
580580
# GH 13872
581-
with pytest.raises(FileNotFoundError, match="\\[Errno 2\\]") as err:
581+
with pytest.raises(FileNotFoundError, match="\\[Errno [0-9]+\\]") as err:
582582
pd.read_csv("doesnt_exist")
583583
assert err.errno == errno.ENOENT
584584

pandas/tests/test_downstream.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def df():
3333

3434

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

0 commit comments

Comments
 (0)