From ce747014cec399e42d7af61ce4eccb0e43066af5 Mon Sep 17 00:00:00 2001 From: Debian Science Team Date: Tue, 11 Jan 2022 21:25:17 +0000 Subject: [PATCH] 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 Forwarded: no Gbp-Pq: Name hurd_compat.patch --- pandas/tests/io/parser/common/test_file_buffer_url.py | 2 +- pandas/tests/io/parser/test_multi_thread.py | 7 ++++++- pandas/tests/io/test_common.py | 4 ++-- pandas/tests/test_downstream.py | 5 +++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pandas/tests/io/parser/common/test_file_buffer_url.py b/pandas/tests/io/parser/common/test_file_buffer_url.py index 2a3d7328..75b4ec0a 100644 --- a/pandas/tests/io/parser/common/test_file_buffer_url.py +++ b/pandas/tests/io/parser/common/test_file_buffer_url.py @@ -79,7 +79,7 @@ def test_nonexistent_path(all_parsers): parser = all_parsers path = f"{tm.rands(10)}.csv" - msg = r"\[Errno 2\]" + msg = r"\[Errno 2\]|\[Errno [0-9]+\] No such file or directory" with pytest.raises(FileNotFoundError, match=msg) as e: parser.read_csv(path) assert path == e.value.filename diff --git a/pandas/tests/io/parser/test_multi_thread.py b/pandas/tests/io/parser/test_multi_thread.py index 981d1d43..bd037306 100644 --- a/pandas/tests/io/parser/test_multi_thread.py +++ b/pandas/tests/io/parser/test_multi_thread.py @@ -4,7 +4,12 @@ parsing files for each parser defined in parsers.py """ from contextlib import ExitStack from io import BytesIO -from multiprocessing.pool import ThreadPool +import pytest +try: + from multiprocessing.pool import ThreadPool + ThreadPool() +except ImportError: + pytest.skip("multiprocessing not available",allow_module_level=True) import numpy as np import pytest diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 41b21af1..e429d2df 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -166,7 +166,7 @@ bar2,12,13,14,15 path = os.path.join(HERE, "data", "does_not_exist." + fn_ext) msg1 = fr"File (b')?.+does_not_exist\.{fn_ext}'? does not exist" - msg2 = fr"\[Errno 2\] No such file or directory: '.+does_not_exist\.{fn_ext}'" + msg2 = fr"\[Errno [0-9]+\] No such file or directory: '.+does_not_exist\.{fn_ext}'" msg3 = "Expected object or value" msg4 = "path_or_buf needs to be a string file path or file-like" msg5 = ( @@ -209,7 +209,7 @@ bar2,12,13,14,15 monkeypatch.setattr(icom, "_expand_user", lambda x: os.path.join("foo", x)) msg1 = fr"File (b')?.+does_not_exist\.{fn_ext}'? does not exist" - msg2 = fr"\[Errno 2\] No such file or directory: '.+does_not_exist\.{fn_ext}'" + msg2 = fr"\[Errno [0-9]+\] No such file or directory: '.+does_not_exist\.{fn_ext}'" msg3 = "Unexpected character found when decoding 'false'" msg4 = "path_or_buf needs to be a string file path or file-like" msg5 = ( diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py index e34ca9e7..1e6af783 100644 --- a/pandas/tests/test_downstream.py +++ b/pandas/tests/test_downstream.py @@ -33,6 +33,11 @@ def df(): # https://github.com/dask/dask/pull/7318 @td.skip_array_manager_not_yet_implemented def test_dask(df): + try: + from multiprocessing.pool import ThreadPool + ThreadPool() + except ImportError: + pytest.skip("multiprocessing not available") toolz = import_module("toolz") # noqa dask = import_module("dask") # noqa -- 2.30.2