Skip to content

Commit 6330f65

Browse files
committed
test: add test for issue 1054 (newer fsspec failing to parse files with 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
1 parent afeeee7 commit 6330f65

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

src/uproot/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import re
1414

15-
__version__ = "5.2.0rc3"
15+
__version__ = "5.2.0rc4"
1616
version = __version__
1717
version_info = tuple(re.split(r"[-\.]", __version__))
1818

tests/test_0692_fsspec_reading.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import os
1616
import sys
1717

18+
is_windows = sys.platform.startswith("win")
19+
1820

1921
@pytest.mark.parametrize(
2022
"urlpath, source_class",
@@ -166,6 +168,61 @@ def test_open_fsspec_xrootd(handler):
166168
assert (data == 194778).all()
167169

168170

171+
@pytest.mark.parametrize(
172+
"handler",
173+
[
174+
uproot.source.file.MemmapSource,
175+
uproot.source.file.MultithreadedFileSource,
176+
uproot.source.fsspec.FSSpecSource,
177+
None,
178+
],
179+
)
180+
@pytest.mark.skipif(
181+
is_windows, reason="Windows does not support colons (':') in filenames"
182+
)
183+
def test_issue_1054_filename_colons(handler):
184+
root_filename = "uproot-issue121.root"
185+
local_path = str(skhep_testdata.data_path(root_filename))
186+
local_path_new = local_path[: -len(root_filename)] + "file:with:colons.root"
187+
os.rename(local_path, local_path_new)
188+
with uproot.open(local_path_new, handler=handler) as f:
189+
data = f["Events/MET_pt"].array(library="np")
190+
assert len(data) == 40
191+
192+
with uproot.open(local_path_new + ":Events", handler=handler) as tree:
193+
data = tree["MET_pt"].array(library="np")
194+
assert len(data) == 40
195+
196+
with uproot.open(local_path_new + ":Events/MET_pt", handler=handler) as branch:
197+
data = branch.array(library="np")
198+
assert len(data) == 40
199+
200+
201+
@pytest.mark.parametrize(
202+
"handler",
203+
[
204+
uproot.source.file.MemmapSource,
205+
uproot.source.file.MultithreadedFileSource,
206+
uproot.source.fsspec.FSSpecSource,
207+
None,
208+
],
209+
)
210+
def test_issue_1054_object_path_split(handler):
211+
root_filename = "uproot-issue121.root"
212+
local_path = str(skhep_testdata.data_path(root_filename))
213+
with uproot.open(local_path, handler=handler) as f:
214+
data = f["Events/MET_pt"].array(library="np")
215+
assert len(data) == 40
216+
217+
with uproot.open(local_path + ":Events", handler=handler) as tree:
218+
data = tree["MET_pt"].array(library="np")
219+
assert len(data) == 40
220+
221+
with uproot.open(local_path + ":Events/MET_pt", handler=handler) as branch:
222+
data = branch.array(library="np")
223+
assert len(data) == 40
224+
225+
169226
def test_fsspec_chunks(server):
170227
pytest.importorskip("aiohttp")
171228

0 commit comments

Comments
 (0)