Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of 'local://' URI Scheme Support #150

Merged
merged 8 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions upath/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
ap-- marked this conversation as resolved.
Show resolved Hide resolved
"gcs": "upath.implementations.cloud.GCSPath",
"gs": "upath.implementations.cloud.GCSPath",
"hdfs": "upath.implementations.hdfs.HDFSPath",
Expand Down
25 changes: 25 additions & 0 deletions upath/tests/implementations/test_http.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
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

from ..cases import BaseTests
from ..utils import skip_on_windows
from ..utils import xfail_if_no_ssl_connection

try:
get_filesystem_class("http")
Expand All @@ -19,6 +22,7 @@ def test_httppath():
assert path.exists()


@xfail_if_no_ssl_connection
def test_httpspath():
path = UPath("https://example.com")
assert isinstance(path, HTTPPath)
Expand All @@ -38,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
Expand Down
13 changes: 13 additions & 0 deletions upath/tests/implementations/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,3 +16,15 @@ def path(self, local_testdir):

def test_is_LocalPath(self):
assert isinstance(self.path, LocalPath)


@skip_on_windows
ap-- marked this conversation as resolved.
Show resolved Hide resolved
@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):
path = f"local://{local_testdir}"
self.path = UPath(path)

def test_is_LocalPath(self):
assert isinstance(self.path, LocalPath)
1 change: 1 addition & 0 deletions upath/tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"hdfs",
"http",
"https",
"local",
"memory",
"s3",
"s3a",
Expand Down
11 changes: 11 additions & 0 deletions upath/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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