Skip to content

Commit a5922ef

Browse files
committed
Causee of the error:
We imported the fairmd.lipids package, whose __init__.py raises RuntimeError when FMDL_DATA_PATH points to a non-existent folder. Develop tests shouldn't trigger that heavy package initialization, so loading the schema from the filesystem keeps them isolated. Now loading the schema directly. If you think, loading the package initialization is necessary, you need to provide it with the proper environment in the test. (Btw, did I mention that unconditional loading of data from an environment variblble was a bad idea?))
1 parent 249d62f commit a5922ef

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

tests/develop/test_autocomplete_metadata.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from importlib.resources import files
21
import importlib.util
32
import json
43
import os
@@ -76,12 +75,16 @@ def test_autocomplete_output_is_schema_compliant(tmp_path, monkeypatch):
7675
mod.main()
7776

7877
generated = yaml.safe_load(metadata_path.read_text(encoding="utf-8"))
79-
with (
80-
files("fairmd.lipids.schema_validation.schema")
81-
.joinpath("metadata_schema.json")
82-
.open("r", encoding="utf-8") as f
83-
):
84-
schema = json.load(f)
78+
schema_path = (
79+
Path(__file__).resolve().parents[2]
80+
/ "src"
81+
/ "fairmd"
82+
/ "lipids"
83+
/ "schema_validation"
84+
/ "schema"
85+
/ "metadata_schema.json"
86+
)
87+
schema = json.loads(schema_path.read_text(encoding="utf-8"))
8588

8689
errors = sorted(Draft7Validator(schema).iter_errors(generated), key=lambda e: e.path)
8790
assert not errors

0 commit comments

Comments
 (0)