diff --git a/pyproject.toml b/pyproject.toml index aea6ba02e0..19f4c7b012 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ classifiers = [ dependencies = [ "click>=8.0.0", # for console scripts "importlib_resources>=1.4.0; python_version < '3.9'", # for resources in schema - "typing_extensions; python_version < '3.11'" # for typing + "typing_extensions; python_version < '3.11'", # for typing "jsonpatch>=1.15", "jsonschema>=4.15.0", # for utils "pyyaml>=5.1", # for parsing CLI equal-delimited options diff --git a/tests/test_upgrade.py b/tests/test_upgrade.py index 01adef4305..5295bcc19e 100644 --- a/tests/test_upgrade.py +++ b/tests/test_upgrade.py @@ -11,10 +11,12 @@ def test_upgrade_bad_version(datadir): def test_upgrade_to_latest(datadir): - ws = json.load(open(datadir.joinpath("workspace_1.0.0.json"), encoding="utf-8")) + with datadir.joinpath("workspace_1.0.0.json").open(encoding="utf-8") as fp: + ws = json.load(fp) pyhf.schema.upgrade().workspace(ws) - ps = json.load(open(datadir.joinpath("workspace_1.0.0.json"), encoding="utf-8")) + with datadir.joinpath("workspace_1.0.0.json").open(encoding="utf-8") as fp: + ps = json.load(fp) pyhf.schema.upgrade().patchset(ps) @@ -22,7 +24,8 @@ def test_1_0_0_workspace(datadir, caplog, monkeypatch): """ Test upgrading a workspace from 1.0.0 to 1.0.1 """ - spec = json.load(open(datadir.joinpath("workspace_1.0.0.json"), encoding="utf-8")) + with datadir.joinpath("workspace_1.0.0.json").open(encoding="utf-8") as fp: + spec = json.load(fp) monkeypatch.setitem(pyhf.schema.versions, 'workspace.json', '1.0.1') with caplog.at_level(logging.INFO, 'pyhf.schema'): @@ -39,7 +42,8 @@ def test_1_0_0_patchset(datadir, caplog, monkeypatch): """ Test upgrading a patchset from 1.0.0 to 1.0.1 """ - spec = json.load(open(datadir.joinpath("patchset_1.0.0.json"), encoding="utf-8")) + with datadir.joinpath("patchset_1.0.0.json").open(encoding="utf-8") as fp: + spec = json.load(fp) monkeypatch.setitem(pyhf.schema.versions, 'patchset.json', '1.0.1') with caplog.at_level(logging.INFO, 'pyhf.schema'): @@ -56,7 +60,8 @@ def test_1_0_1_workspace(datadir): """ Test upgrading a workspace from 1.0.1 to 1.0.1 """ - spec = json.load(open(datadir.joinpath("workspace_1.0.1.json"), encoding="utf-8")) + with datadir.joinpath("workspace_1.0.1.json").open(encoding="utf-8") as fp: + spec = json.load(fp) new_spec = pyhf.schema.upgrade(to_version='1.0.1').workspace(spec) assert new_spec['version'] == '1.0.1' @@ -66,7 +71,8 @@ def test_1_0_1_patchset(datadir): """ Test upgrading a patchset from 1.0.1 to 1.0.1 """ - spec = json.load(open(datadir.joinpath("patchset_1.0.1.json"), encoding="utf-8")) + with datadir.joinpath("patchset_1.0.1.json").open(encoding="utf-8") as fp: + spec = json.load(fp) new_spec = pyhf.schema.upgrade(to_version='1.0.1').patchset(spec) assert new_spec['version'] == '1.0.1'