Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #442 from chrisburr/minimal-testing
Browse files Browse the repository at this point in the history
Allow tests to be ran with minimal dependencies
  • Loading branch information
jpivarski authored Jan 30, 2020
2 parents ced6380 + be5f56c commit dc7de0a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
15 changes: 8 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ environment:
NUMPY: "numpy>=1.15"

install:
- "SET PATH=%PYTHON%;%PATH%"
- "python --version"

build_script:
- "python -m pip install --upgrade pip"
- "pip install %NUMPY%"
- "pip install \"awkward>=0.12.0,<1.0\""
- "python -m pip install %NUMPY%"
- "python -m pip install \"awkward>=0.12.0,<1.0\""
- "python -c \"import awkward; print(awkward.__version__)\""
- "pip install \"uproot-methods>=0.7.0\""
- "python -m pip install \"uproot-methods>=0.7.0\""
- "python -c \"import uproot_methods; print(uproot_methods.__version__)\""
- "pip install cachetools lz4 zstandard mock xxhash"
- "pip install -i https://pypi.anaconda.org/carlkl/simple backports.lzma"
- "pip install pytest pytest-runner pandas requests"
- "python -m pip install cachetools lz4 zstandard mock xxhash"
- "IF \"%PYTHON_VERSION%\"==\"2.7.10\" ( python -m pip install -i https://pypi.anaconda.org/carlkl/simple backports.lzma )"
- "python -m pip install pytest pytest-runner pandas requests"
- "curl -fsS -o tests/samples/Event.root http://scikit-hep.org/uproot/examples/Event.root"
- "pytest -v tests"
- "python -m pytest -v tests"
8 changes: 8 additions & 0 deletions tests/test_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

# BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE

import pytest
try:
import lzma
except ImportError:
lzma = pytest.importorskip('backports.lzma')
lz4 = pytest.importorskip('lz4')
zstandard = pytest.importorskip('zstandard')
import uproot


class Test(object):
def test_compression_identity(self):
assert uproot.open("tests/samples/Zmumu-zlib.root").compression.algoname == "zlib"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
import mock
from requests.exceptions import HTTPError
HTTPError = pytest.importorskip('requests.exceptions').HTTPError

import uproot

Expand Down
1 change: 1 addition & 0 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def test_issue187(self):
assert t.array("V0s.fEtaPos")[-3].tolist() == [-0.390625, 0.046875]

def test_issue213(self):
pytest.importorskip("xxhash")
t = uproot.open("tests/samples/issue213.root")["T"]
assert t["fMCHits.fPosition"].array().x.tolist() == [
[], [], [], [], [], [], [], [42.17024612426758, 50.63192367553711],
Expand Down
10 changes: 6 additions & 4 deletions tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,13 @@ def test_tree_lazy_cached(self):
@pytest.mark.parametrize("use_http", [False, True])
def test_hist_in_tree(self, use_http):
if use_http:
pytest.importorskip("requests")
tree = uproot.open("http://scikit-hep.org/uproot/examples/Event.root")["T"]
else:
path = os.path.join("tests", "samples", "Event.root")
if not os.path.exists(path):
raise pytest.skip()
tree = uproot.open(path)["T"]
else:
tree = uproot.open("http://scikit-hep.org/uproot/examples/Event.root")["T"]
check = [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0,
1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
Expand All @@ -625,12 +626,13 @@ def test_branch_auto_interpretation(self, use_http):
b'fTriggerBits.TObject'
]
if use_http:
pytest.importorskip("requests")
tree = uproot.open("http://scikit-hep.org/uproot/examples/Event.root")["T"]
else:
path = os.path.join("tests", "samples", "Event.root")
if not os.path.exists(path):
raise pytest.skip()
tree = uproot.open(path)["T"]
else:
tree = uproot.open("http://scikit-hep.org/uproot/examples/Event.root")["T"]
branches_without_interp = [b.name for b in tree.allvalues() if b.interpretation is None]
assert branches_without_interp == known_branches_without_interp
assert tree.array("fTracks.fTArray[3]", entrystop=10)[5][10].tolist() == [11.03951644897461, 19.40645980834961, 34.54059982299805]
Expand Down
6 changes: 4 additions & 2 deletions tests/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

# BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE

import pytest
try:
import lzma
except ImportError:
from backports import lzma
import lz4
lzma = pytest.importorskip('backports.lzma')
lz4 = pytest.importorskip('lz4')

import uproot


class Test(object):
sample = {
b"n": [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4],
Expand Down
4 changes: 2 additions & 2 deletions uproot/interp/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def _ftype2dtype(fType, awkward):
elif fType in (uproot.const.kBits, uproot.const.kUInt, uproot.const.kCounter):
return awkward.numpy.dtype(">u4")
elif fType == uproot.const.kLong:
return awkward.numpy.dtype(awkward.numpy.long).newbyteorder(">")
return awkward.numpy.dtype(">i8")
elif fType == uproot.const.kULong:
return awkward.numpy.dtype(">u" + repr(awkward.numpy.dtype(awkward.numpy.long).itemsize))
return awkward.numpy.dtype(">u8")
elif fType == uproot.const.kLong64:
return awkward.numpy.dtype(">i8")
elif fType == uproot.const.kULong64:
Expand Down

0 comments on commit dc7de0a

Please sign in to comment.