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: use file in skhep-testdata for issue #121 #973

Merged
merged 7 commits into from
Oct 5, 2023
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
7 changes: 3 additions & 4 deletions tests/test_0088-read-with-http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import uproot

import skhep_testdata


@pytest.mark.network
def test_issue176():
Expand All @@ -24,10 +26,7 @@ def test_issue176_again():
assert len(data["Y2"]) == 100000


@pytest.mark.network
def test_issue121():
with uproot.open(
"https://github.com/CoffeaTeam/coffea/raw/master/tests/samples/nano_dy.root"
) as f:
with uproot.open(skhep_testdata.data_path("uproot-issue121.root")) as f:
data = f["Events/MET_pt"].array(library="np")
assert len(data) == 40
21 changes: 8 additions & 13 deletions tests/test_0692_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import uproot
import uproot.source.fsspec

import skhep_testdata


@pytest.mark.network
def test_open_fsspec_http():
with uproot.open(
"https://github.com/CoffeaTeam/coffea/raw/master/tests/samples/nano_dy.root",
"https://github.com/scikit-hep/scikit-hep-testdata/raw/v0.4.33/src/skhep_testdata/data/uproot-issue121.root",
http_handler=uproot.source.fsspec.FSSpecSource,
) as f:
data = f["Events/MET_pt"].array(library="np")
Expand All @@ -18,26 +20,19 @@ def test_open_fsspec_http():

@pytest.mark.network
def test_open_fsspec_github():
pytest.skip("not working yet")
pytest.skip(
"skipping due to GitHub API rate limitations - this should work fine - see https://github.com/scikit-hep/uproot5/pull/973 for details"
)
with uproot.open(
"github://CoffeaTeam:coffea@master/tests/samples/nano_dy.root",
"github://scikit-hep:scikit-hep-testdata@v0.4.33/src/skhep_testdata/data/uproot-issue121.root",
http_handler=uproot.source.fsspec.FSSpecSource,
) as f:
data = f["Events/MET_pt"].array(library="np")
assert len(data) == 40


@pytest.mark.network
def test_open_fsspec_local(tmp_path):
url = "https://github.com/CoffeaTeam/coffea/raw/master/tests/samples/nano_dy.root"

# download file to local
local_path = str(tmp_path / "nano_dy.root")
import fsspec

with fsspec.open(url) as f:
with open(local_path, "wb") as fout:
fout.write(f.read())
local_path = skhep_testdata.data_path("uproot-issue121.root")

with uproot.open(
local_path,
Expand Down