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

test: add test for issue 1054 (newer fsspec failing to parse files with colons in name) #1055

Merged
merged 7 commits into from
Dec 11, 2023
Merged
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
57 changes: 57 additions & 0 deletions tests/test_0692_fsspec_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import os
import sys

is_windows = sys.platform.startswith("win")


@pytest.mark.parametrize(
"urlpath, source_class",
Expand Down Expand Up @@ -166,6 +168,61 @@ def test_open_fsspec_xrootd(handler):
assert (data == 194778).all()


@pytest.mark.parametrize(
"handler",
[
uproot.source.file.MemmapSource,
uproot.source.file.MultithreadedFileSource,
uproot.source.fsspec.FSSpecSource,
None,
],
)
@pytest.mark.skipif(
is_windows, reason="Windows does not support colons (':') in filenames"
)
def test_issue_1054_filename_colons(handler):
root_filename = "uproot-issue121.root"
local_path = str(skhep_testdata.data_path(root_filename))
local_path_new = local_path[: -len(root_filename)] + "file:with:colons.root"
os.rename(local_path, local_path_new)
with uproot.open(local_path_new, handler=handler) as f:
data = f["Events/MET_pt"].array(library="np")
assert len(data) == 40

with uproot.open(local_path_new + ":Events", handler=handler) as tree:
data = tree["MET_pt"].array(library="np")
assert len(data) == 40

with uproot.open(local_path_new + ":Events/MET_pt", handler=handler) as branch:
data = branch.array(library="np")
assert len(data) == 40


@pytest.mark.parametrize(
"handler",
[
uproot.source.file.MemmapSource,
uproot.source.file.MultithreadedFileSource,
uproot.source.fsspec.FSSpecSource,
None,
],
)
def test_issue_1054_object_path_split(handler):
root_filename = "uproot-issue121.root"
local_path = str(skhep_testdata.data_path(root_filename))
with uproot.open(local_path, handler=handler) as f:
data = f["Events/MET_pt"].array(library="np")
assert len(data) == 40

with uproot.open(local_path + ":Events", handler=handler) as tree:
data = tree["MET_pt"].array(library="np")
assert len(data) == 40

with uproot.open(local_path + ":Events/MET_pt", handler=handler) as branch:
data = branch.array(library="np")
assert len(data) == 40


def test_fsspec_chunks(server):
pytest.importorskip("aiohttp")

Expand Down
Loading