From e6b8493f1dc95c8a5dba18f0ef2cc8c0d3338e6c Mon Sep 17 00:00:00 2001 From: Gabriel Lesperance <611342+glesperance@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:11:12 -0400 Subject: [PATCH 1/6] Update test_local.py --- upath/tests/implementations/test_local.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/upath/tests/implementations/test_local.py b/upath/tests/implementations/test_local.py index cb60cd03..0527463d 100644 --- a/upath/tests/implementations/test_local.py +++ b/upath/tests/implementations/test_local.py @@ -15,3 +15,13 @@ def path(self, local_testdir): def test_is_LocalPath(self): assert isinstance(self.path, LocalPath) + +@skip_on_windows +class TestRayIOFSSpecLocal(BaseTests): + @pytest.fixture(autouse=True) + def path(self, local_testdir): + path = f"local://{local_testdir}" + self.path = UPath(path) + + def test_is_LocalPath(self): + assert isinstance(self.path, LocalPath) From 2bec00cd3d578045d95c507e70cf944ac5b68db7 Mon Sep 17 00:00:00 2001 From: Gabriel Lesperance <611342+glesperance@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:15:20 -0400 Subject: [PATCH 2/6] Update registry.py --- upath/registry.py | 1 + 1 file changed, 1 insertion(+) diff --git a/upath/registry.py b/upath/registry.py index 085b2274..1953caa3 100644 --- a/upath/registry.py +++ b/upath/registry.py @@ -64,6 +64,7 @@ class _Registry(MutableMapping[str, "type[upath.core.UPath]"]): "adl": "upath.implementations.cloud.AzurePath", "az": "upath.implementations.cloud.AzurePath", "file": "upath.implementations.local.LocalPath", + "local": "upath.implementations.local.LocalPath", "gcs": "upath.implementations.cloud.GCSPath", "gs": "upath.implementations.cloud.GCSPath", "hdfs": "upath.implementations.hdfs.HDFSPath", From e274d684c58d0a3720f427ae03f087eb4dae7012 Mon Sep 17 00:00:00 2001 From: Gabriel Lesperance <611342+glesperance@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:38:54 -0400 Subject: [PATCH 3/6] Linting via nox --- upath/tests/implementations/test_local.py | 1 + 1 file changed, 1 insertion(+) diff --git a/upath/tests/implementations/test_local.py b/upath/tests/implementations/test_local.py index 0527463d..96d958fa 100644 --- a/upath/tests/implementations/test_local.py +++ b/upath/tests/implementations/test_local.py @@ -16,6 +16,7 @@ def path(self, local_testdir): def test_is_LocalPath(self): assert isinstance(self.path, LocalPath) + @skip_on_windows class TestRayIOFSSpecLocal(BaseTests): @pytest.fixture(autouse=True) From 6b514026a70859089c5a9f0921d671bce41cc0bd Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Thu, 25 Jan 2024 10:39:20 +0100 Subject: [PATCH 4/6] upath: add local to registry tests, skip local on old fsspec version --- upath/tests/implementations/test_local.py | 2 ++ upath/tests/test_registry.py | 1 + 2 files changed, 3 insertions(+) diff --git a/upath/tests/implementations/test_local.py b/upath/tests/implementations/test_local.py index 96d958fa..437c6f55 100644 --- a/upath/tests/implementations/test_local.py +++ b/upath/tests/implementations/test_local.py @@ -4,6 +4,7 @@ from upath.implementations.local import LocalPath from upath.tests.cases import BaseTests from upath.tests.utils import skip_on_windows +from upath.tests.utils import xfail_if_version @skip_on_windows @@ -18,6 +19,7 @@ def test_is_LocalPath(self): @skip_on_windows +@xfail_if_version("fsspec", lt="2023.10.0", reason="requires fsspec>=2023.10.0") class TestRayIOFSSpecLocal(BaseTests): @pytest.fixture(autouse=True) def path(self, local_testdir): diff --git a/upath/tests/test_registry.py b/upath/tests/test_registry.py index 93388f11..19f38d4e 100644 --- a/upath/tests/test_registry.py +++ b/upath/tests/test_registry.py @@ -17,6 +17,7 @@ "hdfs", "http", "https", + "local", "memory", "s3", "s3a", From 9f7fb81bfea704fc19cd7551880de62dc99c0a40 Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Thu, 25 Jan 2024 14:36:46 +0100 Subject: [PATCH 5/6] tests: xfail https test on ssl errors --- upath/tests/implementations/test_http.py | 2 ++ upath/tests/utils.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/upath/tests/implementations/test_http.py b/upath/tests/implementations/test_http.py index 8bcc5ccb..885010ab 100644 --- a/upath/tests/implementations/test_http.py +++ b/upath/tests/implementations/test_http.py @@ -6,6 +6,7 @@ from ..cases import BaseTests from ..utils import skip_on_windows +from ..utils import xfail_if_no_ssl_connection try: get_filesystem_class("http") @@ -19,6 +20,7 @@ def test_httppath(): assert path.exists() +@xfail_if_no_ssl_connection def test_httpspath(): path = UPath("https://example.com") assert isinstance(path, HTTPPath) diff --git a/upath/tests/utils.py b/upath/tests/utils.py index bb73141a..d25df0c1 100644 --- a/upath/tests/utils.py +++ b/upath/tests/utils.py @@ -33,3 +33,14 @@ def xfail_if_version(module, *, reason, **conditions): for op, val in conditions.items(): cond &= getattr(operator, op)(ver, Version(val)) return pytest.mark.xfail(cond, reason=reason) + + +def xfail_if_no_ssl_connection(func): + try: + import requests + + requests.get("https://example.com") + except (ImportError, requests.exceptions.SSLError): + return pytest.mark.xfail(reason="No SSL connection")(func) + else: + return func From 2d4457c97a2c3858831c59b2325d57ded7fc44f5 Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Thu, 25 Jan 2024 14:37:37 +0100 Subject: [PATCH 6/6] tests: xfail http glob test for fsspec>2023.10.0 --- upath/tests/implementations/test_http.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/upath/tests/implementations/test_http.py b/upath/tests/implementations/test_http.py index 885010ab..c585437e 100644 --- a/upath/tests/implementations/test_http.py +++ b/upath/tests/implementations/test_http.py @@ -1,5 +1,7 @@ import pytest # noqa: F401 +from fsspec import __version__ as fsspec_version from fsspec import get_filesystem_class +from packaging.version import Version from upath import UPath from upath.implementations.http import HTTPPath @@ -40,6 +42,27 @@ def test_work_at_root(self): def test_mkdir(self): pass + @pytest.mark.parametrize( + "pattern", + ( + "*.txt", + pytest.param( + "*", + marks=pytest.mark.xfail(reason="requires fsspec<=2023.10.0") + if Version(fsspec_version) > Version("2023.10.0") + else (), + ), + pytest.param( + "**/*.txt", + marks=pytest.mark.xfail(reason="requires fsspec>=2023.9.0") + if Version(fsspec_version) < Version("2023.9.0") + else (), + ), + ), + ) + def test_glob(self, pathlib_base, pattern): + super().test_glob(pathlib_base, pattern) + @pytest.mark.skip def test_mkdir_exists_ok_false(self): pass