Avoid test failures on Hurd
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Mon, 21 Oct 2024 18:43:11 +0000 (19:43 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Mon, 21 Oct 2024 18:43:11 +0000 (19:43 +0100)
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 <rebecca_palmer@zoho.com>
Forwarded: no

Gbp-Pq: Name hurd_compat.patch

pandas/tests/io/parser/common/test_file_buffer_url.py
pandas/tests/io/parser/common/test_float.py
pandas/tests/io/parser/test_multi_thread.py
pandas/tests/io/test_common.py
pandas/tests/test_downstream.py

index a7a8d031da215b95b9145d1a55a6cf8e5d7d9555..37f5a4c47bc3dcb296767daecb3dbf881968c642 100644 (file)
@@ -100,7 +100,7 @@ def test_nonexistent_path(all_parsers):
     parser = all_parsers
     path = f"{uuid.uuid4()}.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
@@ -111,7 +111,7 @@ def test_no_permission(all_parsers):
     # GH 23784
     parser = all_parsers
 
-    msg = r"\[Errno 13\]"
+    msg = r"\[Errno 13\]|\[Errno [0-9]+\] Permission denied"
     with tm.ensure_clean() as path:
         os.chmod(path, 0)  # make file unreadable
 
index 6069c239362976cc242548a0dc52236ddb7d37d8..ed1a40bf054b2da7f31e524fc98f07219b80dc19 100644 (file)
@@ -67,7 +67,7 @@ def test_too_many_exponent_digits(all_parsers_all_precisions, exp, request):
     data = f"data\n10E{exp}"
     result = parser.read_csv(StringIO(data), float_precision=precision)
     if precision == "round_trip":
-        if exp == 999999999999999999 and is_platform_linux():
+        if exp == 999999999999999999:
             mark = pytest.mark.xfail(reason="GH38794, on Linux gives object result")
             request.applymarker(mark)
 
index 704ca010f650674caccf979f311b3d9dd0557751..85921e4252f52fe765665f0618b8d00e95cd235b 100644 (file)
@@ -4,7 +4,13 @@ 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
+    with ThreadPool():
+        pass
+except ImportError:
+    pytest.skip("multiprocessing not available",allow_module_level=True)
 
 import numpy as np
 import pytest
index cddbd2c8c2e9f6351bb1ab46eba6a21813589e44..4b79ff7bdf643f932ba57a45ce5e655d4ef8cb9a 100644 (file)
@@ -200,16 +200,16 @@ Look,a snake,🐍"""
 
         path = os.path.join(HERE, "data", "does_not_exist." + fn_ext)
         msg1 = rf"File (b')?.+does_not_exist\.{fn_ext}'? does not exist"
-        msg2 = rf"\[Errno 2\] No such file or directory: '.+does_not_exist\.{fn_ext}'"
+        msg2 = rf"\[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 = (
-            rf"\[Errno 2\] File .+does_not_exist\.{fn_ext} does not exist: "
+            rf"\[Errno [0-9]+\] File .+does_not_exist\.{fn_ext} does not exist: "
             rf"'.+does_not_exist\.{fn_ext}'"
         )
-        msg6 = rf"\[Errno 2\] 没有那个文件或目录: '.+does_not_exist\.{fn_ext}'"
+        msg6 = rf"\[Errno [0-9]+\] 没有那个文件或目录: '.+does_not_exist\.{fn_ext}'"
         msg7 = (
-            rf"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'"
+            rf"\[Errno [0-9]+\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'"
         )
         msg8 = rf"Failed to open local file.+does_not_exist\.{fn_ext}"
 
@@ -270,16 +270,16 @@ Look,a snake,🐍"""
         monkeypatch.setattr(icom, "_expand_user", lambda x: os.path.join("foo", x))
 
         msg1 = rf"File (b')?.+does_not_exist\.{fn_ext}'? does not exist"
-        msg2 = rf"\[Errno 2\] No such file or directory: '.+does_not_exist\.{fn_ext}'"
+        msg2 = rf"\[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 = (
-            rf"\[Errno 2\] File .+does_not_exist\.{fn_ext} does not exist: "
+            rf"\[Errno [0-9]+\] File .+does_not_exist\.{fn_ext} does not exist: "
             rf"'.+does_not_exist\.{fn_ext}'"
         )
-        msg6 = rf"\[Errno 2\] 没有那个文件或目录: '.+does_not_exist\.{fn_ext}'"
+        msg6 = rf"\[Errno [0-9]+\] 没有那个文件或目录: '.+does_not_exist\.{fn_ext}'"
         msg7 = (
-            rf"\[Errno 2\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'"
+            rf"\[Errno [0-9]+\] File o directory non esistente: '.+does_not_exist\.{fn_ext}'"
         )
         msg8 = rf"Failed to open local file.+does_not_exist\.{fn_ext}"
 
@@ -610,7 +610,7 @@ def test_bad_encdoing_errors():
 
 def test_errno_attribute():
     # GH 13872
-    with pytest.raises(FileNotFoundError, match="\\[Errno 2\\]") as err:
+    with pytest.raises(FileNotFoundError, match="\\[Errno [0-9]+\\]") as err:
         pd.read_csv("doesnt_exist")
         assert err.errno == errno.ENOENT
 
index 51ce73ef54300c5d2f9be4e3988de77843a61a8e..03424b262e9cdc5b4e6a2bb0ccb16d4689e5d6f7 100644 (file)
@@ -31,6 +31,12 @@ def df():
 
 
 def test_dask(df):
+    try:
+        from multiprocessing.pool import ThreadPool
+        with ThreadPool():
+            pass
+    except ImportError:
+        pytest.skip("multiprocessing not available")
     # dask sets "compute.use_numexpr" to False, so catch the current value
     # and ensure to reset it afterwards to avoid impacting other tests
     olduse = pd.get_option("compute.use_numexpr")