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
Prev Previous commit
Next Next commit
add test to cover public api
  • Loading branch information
kratsg committed Mar 23, 2022
commit 2d400b835b2d8d88f7cba73fd1752a7edc1c909e
21 changes: 21 additions & 0 deletions tests/test_public_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import pyhf
import numpy as np
import pathlib


@pytest.fixture(scope='function')
Expand Down Expand Up @@ -200,3 +201,23 @@ def test_pdf_batched(backend):

model.pdf(pars, data)
model.expected_data(pars)


def test_set_schema_path(monkeypatch):
monkeypatch.setattr(
pyhf.schema.variables, 'schemas', pyhf.schema.variables.schemas, raising=True
)

new_path = pathlib.Path('a/new/path')
pyhf.schema(new_path)
assert pyhf.schema.path == new_path


def test_set_schema_path_context(monkeypatch):
monkeypatch.setattr(
pyhf.schema.variables, 'schemas', pyhf.schema.variables.schemas, raising=True
)

new_path = pathlib.Path('a/new/path')
with pyhf.schema(new_path):
assert pyhf.schema.path == new_path