|
15 | 15 | import os
|
16 | 16 | import sys
|
17 | 17 |
|
| 18 | +is_windows = sys.platform.startswith("win") |
| 19 | + |
18 | 20 |
|
19 | 21 | @pytest.mark.parametrize(
|
20 | 22 | "urlpath, source_class",
|
@@ -166,6 +168,61 @@ def test_open_fsspec_xrootd(handler):
|
166 | 168 | assert (data == 194778).all()
|
167 | 169 |
|
168 | 170 |
|
| 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 | + |
169 | 226 | def test_fsspec_chunks(server):
|
170 | 227 | pytest.importorskip("aiohttp")
|
171 | 228 |
|
|
0 commit comments