Skip to content

Commit

Permalink
test: add test for issue 1054 (newer fsspec failing to parse files wi…
Browse files Browse the repository at this point in the history
…th colons in name) (#1055)

* add test for issue 1054

* additional test

* make sure fsspec fix works

* try new test in older fsspec version (need to test windows)

* skip test in windows due to colons in name

* add explicit object-path split with open

* revert use fsspec fork in ci
  • Loading branch information
lobis committed Dec 12, 2023
1 parent 71ccdbd commit 5c48ba7
Showing 1 changed file with 57 additions and 0 deletions.
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

0 comments on commit 5c48ba7

Please sign in to comment.