Skip to content

Commit 4e7954f

Browse files
committed
@sanderegg review: rm cache
1 parent cc66753 commit 4e7954f

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.vscode/launch.template.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"--log-cli-level=INFO",
1616
"--pdb",
1717
"--setup-show",
18+
"--durations=5",
1819
"-sx",
1920
"-vv",
2021
"${file}"

packages/pytest-simcore/src/pytest_simcore/openapi_specs.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# pylint: disable=unused-variable
44
# pylint: disable=too-many-arguments
55

6+
import json
67
from collections.abc import Callable
78
from copy import deepcopy
8-
from functools import lru_cache
99
from pathlib import Path
1010
from typing import Any, NamedTuple
1111

@@ -27,23 +27,32 @@ class Entrypoint(NamedTuple):
2727
path: str
2828

2929

30-
@lru_cache # ANE: required to boost tests speed, gains 3.5s per test
30+
@pytest.fixture
31+
def openapi_specs_path() -> Path:
32+
# NOTE: cannot be defined as a session scope because it is designed to be overriden
33+
pytest.fail(reason="Must be overriden in caller test suite")
34+
35+
3136
def _load(file: Path, base_uri: str = "") -> dict:
37+
match file.suffix:
38+
case ".yaml" | ".yml":
39+
loaded = yaml.safe_load(file.read_text())
40+
case "json":
41+
loaded = json.loads(file.read_text())
42+
case _:
43+
msg = f"Expect yaml or json, got {file.suffix}"
44+
raise ValueError(msg)
45+
3246
# SEE https://jsonref.readthedocs.io/en/latest/#lazy-load-and-load-on-repr
3347
data: dict = jsonref.replace_refs( # type: ignore
34-
yaml.safe_load(file.read_text()),
48+
loaded,
3549
base_uri=base_uri,
3650
lazy_load=True, # this data will be iterated
3751
merge_props=False,
3852
)
3953
return data
4054

4155

42-
@pytest.fixture
43-
def openapi_specs_path() -> Path:
44-
pytest.fail(reason="Must be overriden in caller tests package")
45-
46-
4756
@pytest.fixture
4857
def openapi_specs(openapi_specs_path: Path) -> dict[str, Any]:
4958
assert openapi_specs_path.is_file()

0 commit comments

Comments
 (0)