Skip to content

Commit

Permalink
test: use file in skhep-testdata for issue #121 (#973)
Browse files Browse the repository at this point in the history
* use file in skhep testdata

* remove hyphen

* use tag instead of branch (#973 (comment))

* remove network pytest mark (#973 (comment))

* use proper http links instead of local paths

* update skip comment

* update comment
  • Loading branch information
lobis authored Oct 5, 2023
1 parent 546b0cb commit 576fbdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
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:[email protected]/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

0 comments on commit 576fbdb

Please sign in to comment.