Skip to content

Commit 184ff54

Browse files
committed
tests(schemaview): optimize execution
Avoid opening the same schema 9 times for very similar tests. Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
1 parent b2206a4 commit 184ff54

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/test_utils/test_schemaview.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ def schema_view_attributes() -> SchemaView:
6262
"""Fixture for a SchemaView for testing attribute edge cases."""
6363
return SchemaView(os.path.join(INPUT_DIR, "attribute_edge_cases.yaml"))
6464

65+
@pytest.fixture(scope="session")
66+
def schema_view_inlined() -> SchemaView:
67+
"""Fixture for a SchemaView for testing attribute edge cases."""
68+
return SchemaView(os.path.join(INPUT_DIR, "schemaview_is_inlined.yaml"))
69+
6570

6671
def test_children_method(schema_view_no_imports: SchemaView) -> None:
6772
"""Test retrieval of the children of a class."""
@@ -930,11 +935,10 @@ def test_mergeimports() -> None:
930935
],
931936
)
932937
def test_is_inlined(slot_name: str, expected_result: bool) -> None:
938+
def test_is_inlined(schema_view_inlined: SchemaView, slot_name: str, expected_result: bool) -> None:
933939
"""Tests for slots being inlined or not."""
934-
schema_path = os.path.join(INPUT_DIR, "schemaview_is_inlined.yaml")
935-
sv = SchemaView(schema_path)
936-
slot = sv.get_slot(slot_name)
937-
assert sv.is_inlined(slot) == expected_result
940+
slot = schema_view_inlined.get_slot(slot_name)
941+
assert schema_view_inlined.is_inlined(slot) == expected_result
938942

939943

940944
def test_materialize_nonscalar_slot_usage() -> None:

0 commit comments

Comments
 (0)