Skip to content

Commit 2cfa4af

Browse files
test: harden plural subgraphs harness against fixture errors
Two defensive checks added per PR review feedback: 1. _compile_subgraphs_map now raises ValueError if an entry's `name` field is present and disagrees with the dict key, or if the name already exists in the registry (collision with the singular subgraph: form or duplicate plural entry). Both are fixture authoring bugs the harness should surface, not paper over. 2. _unsupported_directive now also walks every entry under the plural `subgraphs:` map. A future fixture with fan_out or a flaky directive inside a nested subgraph will skip cleanly instead of failing noisily.
1 parent 78a1597 commit 2cfa4af

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/conformance/test_conformance.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ def scan(graph: Any) -> str | None:
100100
return hit
101101
if (hit := scan(spec.get("subgraph"))) is not None:
102102
return hit
103+
for sub_spec in spec.get("subgraphs", {}).values():
104+
if (hit := scan(sub_spec)) is not None:
105+
return hit
103106
return None
104107

105108

@@ -139,6 +142,15 @@ def _compile_subgraphs_map(
139142
continue
140143
# Plural form omits the `name:` field (the dict key IS the name);
141144
# synthesize it for build_graph's existing singular-form lookup.
145+
# Validate against fixture authoring errors first.
146+
existing_name = sub_spec.get("name")
147+
if existing_name is not None and existing_name != name:
148+
raise ValueError(f"subgraph dict key {name!r} does not match name field {existing_name!r}")
149+
if name in registry:
150+
raise ValueError(
151+
f"subgraph name {name!r} is already registered "
152+
f"(collision with singular subgraph: form or duplicate plural entry)"
153+
)
142154
sub_with_name = {**sub_spec, "name": name}
143155
sub_built = build_graph(
144156
sub_with_name,

0 commit comments

Comments
 (0)