Skip to content

Commit 2c5a2f1

Browse files
committed
tests(schemaview): optimize execution
Avoid opening the same schema 9 times for very similar tests. Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
1 parent c38bfae commit 2c5a2f1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/test_utils/test_schemaview.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,12 @@ def test_all_classes_ordered_by(sv_ordering_tests: SchemaView, ordered_by: str)
886886
assert list(sv_ordering_tests.all_classes(ordered_by=ordered_by).keys()) == ORDERING_TESTS[ordered_by]
887887

888888

889+
@pytest.fixture(scope="session")
890+
def schema_view_inlined() -> SchemaView:
891+
"""Fixture for a SchemaView for testing attribute edge cases."""
892+
return SchemaView(os.path.join(INPUT_DIR, "schemaview_is_inlined.yaml"))
893+
894+
889895
def test_children_method(schema_view_no_imports: SchemaView) -> None:
890896
"""Test retrieval of the children of a class."""
891897
view = schema_view_no_imports
@@ -1478,12 +1484,10 @@ def test_materialize_patterns_attribute() -> None:
14781484
("inlined_as_list_integer", False),
14791485
],
14801486
)
1481-
def test_is_inlined(slot_name: str, expected_result: bool) -> None:
1487+
def test_is_inlined(schema_view_inlined: SchemaView, slot_name: str, expected_result: bool) -> None:
14821488
"""Tests for slots being inlined or not."""
1483-
schema_path = os.path.join(INPUT_DIR, "schemaview_is_inlined.yaml")
1484-
sv = SchemaView(schema_path)
1485-
slot = sv.get_slot(slot_name)
1486-
assert sv.is_inlined(slot) == expected_result
1489+
slot = schema_view_inlined.get_slot(slot_name)
1490+
assert schema_view_inlined.is_inlined(slot) == expected_result
14871491

14881492

14891493
def test_materialize_nonscalar_slot_usage() -> None:

0 commit comments

Comments
 (0)