Skip to content

Commit 5d9572e

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 de409a5 commit 5d9572e

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_nonexistent_path(all_parsers):
9090
parser = all_parsers
9191
path = f"{uuid.uuid4()}.csv"
9292

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

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

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

+1-1
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

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
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+
ThreadPool()
11+
except ImportError:
12+
pytest.skip("multiprocessing not available",allow_module_level=True)
813

914
import numpy as np
1015
import pytest

pandas/tests/io/test_common.py

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

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

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

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

@@ -583,7 +583,7 @@ def test_bad_encdoing_errors():
583583

584584
def test_errno_attribute():
585585
# GH 13872
586-
with pytest.raises(FileNotFoundError, match="\\[Errno 2\\]") as err:
586+
with pytest.raises(FileNotFoundError, match="\\[Errno [0-9]+\\]") as err:
587587
pd.read_csv("doesnt_exist")
588588
assert err.errno == errno.ENOENT
589589

pandas/tests/test_downstream.py

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def df():
4040

4141
@pytest.mark.filterwarnings("ignore:.*64Index is deprecated:FutureWarning")
4242
def test_dask(df):
43+
try:
44+
from multiprocessing.pool import ThreadPool
45+
ThreadPool()
46+
except ImportError:
47+
pytest.skip("multiprocessing not available")
4348

4449
# dask sets "compute.use_numexpr" to False, so catch the current value
4550
# and ensure to reset it afterwards to avoid impacting other tests

0 commit comments

Comments
 (0)