Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,16 @@ class TestPydanticTypePages:
_SCHEMA_ROOT = "overture.schema"

@pytest.fixture(scope="class")
def pages(self) -> list:
@classmethod
def pages(cls) -> list:
"""Generate all pages from real discovered models."""
models = discover_models()
model_specs: list[ModelSpec] = [
spec
for key, entry in models.items()
if (spec := extract_model_spec(key, entry)) is not None
]
return generate_markdown_pages(model_specs, self._SCHEMA_ROOT)
return generate_markdown_pages(model_specs, cls._SCHEMA_ROOT)

def test_http_url_page_exists(self, pages: list) -> None:
"""Pipeline produces a page for HttpUrl under pydantic/networks/."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,8 @@ class TestStructNestedUnionWithVariantFields:
"""

@pytest.fixture(scope="class")
def discriminated_union_ref_spec(self) -> RecordSpec:
@classmethod
def discriminated_union_ref_spec(cls) -> RecordSpec:
"""A `RecordSpec` whose `nested` field holds a `UnionRef` with a full discriminator."""
union_spec = union_spec_for("Synthetic", _SyntheticUnionFixtures.SyntheticUnion)
field = FieldSpec(
Expand Down Expand Up @@ -1476,24 +1477,28 @@ def test_target_is_nested_inner_array(self) -> None:

class TestSegmentUnionChecks:
@pytest.fixture(scope="class")
def segment_spec(self) -> ModelSpec:
@classmethod
def segment_spec(cls) -> ModelSpec:
return discover_feature("Segment")

@pytest.fixture(scope="class")
@classmethod
def segment_checks(
self, segment_spec: ModelSpec
cls, segment_spec: ModelSpec
) -> tuple[list[Check], list[ModelCheck]]:
return build_checks(segment_spec)

@pytest.fixture(scope="class")
@classmethod
def field_nodes(
self, segment_checks: tuple[list[Check], list[ModelCheck]]
cls, segment_checks: tuple[list[Check], list[ModelCheck]]
) -> list[Check]:
return segment_checks[0]

@pytest.fixture(scope="class")
@classmethod
def model_nodes(
self, segment_checks: tuple[list[Check], list[ModelCheck]]
cls, segment_checks: tuple[list[Check], list[ModelCheck]]
) -> list[ModelCheck]:
return segment_checks[1]

Expand Down Expand Up @@ -1693,25 +1698,30 @@ class TestUnionInsideArray:
"""UNION-kind fields nested inside list[] produce variant-gated checks."""

@pytest.fixture(scope="class")
def results(self) -> tuple[list[Check], list[ModelCheck]]:
@classmethod
def results(cls) -> tuple[list[Check], list[ModelCheck]]:
return build_checks(spec_for_model(_Wrapper))

@pytest.fixture(scope="class")
def field_nodes(self, results: tuple[list[Check], list[ModelCheck]]) -> list[Check]:
@classmethod
def field_nodes(cls, results: tuple[list[Check], list[ModelCheck]]) -> list[Check]:
return results[0]

@pytest.fixture(scope="class")
@classmethod
def model_nodes(
self, results: tuple[list[Check], list[ModelCheck]]
cls, results: tuple[list[Check], list[ModelCheck]]
) -> list[ModelCheck]:
return results[1]

@pytest.fixture(scope="class")
def a_nodes(self, field_nodes: list[Check]) -> list[Check]:
@classmethod
def a_nodes(cls, field_nodes: list[Check]) -> list[Check]:
return [n for n in field_nodes if n.target == _path("items[].a_field")]

@pytest.fixture(scope="class")
def b_nodes(self, field_nodes: list[Check]) -> list[Check]:
@classmethod
def b_nodes(cls, field_nodes: list[Check]) -> list[Check]:
return [n for n in field_nodes if n.target == _path("items[].b_field")]

def test_a_field_check_produced(self, a_nodes: list[Check]) -> None:
Expand Down Expand Up @@ -1761,7 +1771,8 @@ class TestTopLevelUnionColumnPath:
"""Top-level union (not inside array) exclusivity nodes have column_path=None."""

@pytest.fixture(scope="class")
def model_nodes(self) -> list[ModelCheck]:
@classmethod
def model_nodes(cls) -> list[ModelCheck]:
return _union_model_nodes("Synthetic", _SyntheticUnionFixtures.SyntheticUnion)

def test_forbid_if_column_path_is_none(self, model_nodes: list[ModelCheck]) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,8 @@ class TestVariantGatedArrayLambdaScope:
"""Variant gating for ARRAY-shaped nodes must be inside the lambda, not wrapping it."""

@pytest.fixture(scope="class")
def rendered_source(self) -> str:
@classmethod
def rendered_source(cls) -> str:
class _Base(BaseModel):
kind: str

Expand Down Expand Up @@ -1308,7 +1309,8 @@ class TestTopLevelVariantGatedArray:
"""When the array column itself is variant-conditional, discriminator wraps array_check."""

@pytest.fixture(scope="class")
def surface_check(self) -> Check:
@classmethod
def surface_check(cls) -> Check:
"""ARRAY check with top-level discriminator -- surface only exists for subtype='a'."""
return Check(
descriptors=(ExpressionDescriptor(function="check_required"),),
Expand All @@ -1317,7 +1319,8 @@ def surface_check(self) -> Check:
)

@pytest.fixture(scope="class")
def surface_value_check(self) -> Check:
@classmethod
def surface_value_check(cls) -> Check:
"""ARRAY check with leaf path and top-level discriminator."""
return Check(
descriptors=(ExpressionDescriptor(function="check_required"),),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def test_dict_str_str_maps_to_map_type(self, fields: list[SchemaField]) -> None:

class TestDivisionAreaSchema:
@pytest.fixture(scope="class")
def fields(self) -> list[SchemaField]:
@classmethod
def fields(cls) -> list[SchemaField]:
return build_schema(spec_for_model(DivisionArea))

def test_id_field_is_string_type(self, fields: list[SchemaField]) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,8 @@ def test_per_arm_label_matches_module_label(self) -> None:

class TestTestLayer:
@pytest.fixture(scope="class")
def empty_source(self) -> str:
@classmethod
def empty_source(cls) -> str:
return render_test_module("test", [], [])

def test_test_scenario_sparse_present(self, empty_source: str) -> None:
Expand Down
Loading
Loading