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

feat: Add contextlib support to pyhf.schema API #1818

Merged
merged 14 commits into from
Mar 23, 2022
Next Next commit
add test
  • Loading branch information
kratsg committed Mar 23, 2022
commit feb51761ee2c3342e62125628c6f61500650483e
14 changes: 11 additions & 3 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@ def test_schema_changeable(datadir):
pyhf.Workspace(json.load(open(datadir / 'customschema' / 'custom.json')))

old_path = pyhf.schema.path
pyhf.schema(datadir / 'customschema')
new_path = datadir / 'customschema'
pyhf.schema(new_path)
assert pyhf.schema.path != old_path
assert pyhf.schema.path == datadir / 'customschema'
assert pyhf.Workspace(json.load(open(datadir / 'customschema' / 'custom.json')))
assert pyhf.schema.path == new_path
assert pyhf.Workspace(json.load(open(new_path / 'custom.json')))
pyhf.schema(old_path)

assert pyhf.schema.path == old_path
with pyhf.schema(new_path):
assert pyhf.schema.path != old_path
assert pyhf.schema.path == new_path
assert pyhf.Workspace(json.load(open(new_path / 'custom.json')))
assert pyhf.schema.path == old_path


def test_no_channels():
spec = {'channels': []}
Expand Down