@@ -963,20 +963,14 @@ def test_gate_reads_the_shared_indexed_segment_definition(monkeypatch):
963963def test_gate_reports_the_leaves_the_evaluator_actually_reached (monkeypatch ):
964964 """The gate's operands come from the evaluator's own walk, not a second parse.
965965
966- If `_evaluate_simple_expression` stops treating something as a leaf — which
967- is what unwrapping a parenthesised group does — the gate stops checking it,
968- with no change to the gate itself.
966+ What `_evaluate_simple_expression` treats as a leaf is what the gate checks.
967+ Unwrapping a parenthesised group takes that group off the list, so the gate
968+ stops checking it, with no change to the gate itself.
969969 """
970970 grouped = "(inputs.a or inputs.b) and inputs.c"
971- assert expressions ._unresolvable_term (grouped ) is not None
972-
973- real = expressions ._evaluate_simple_expression
974-
975- def unwrapping (expr , namespace ):
976- stripped = expr .strip ()
977- if stripped .startswith ("(" ) and stripped .endswith (")" ):
978- return unwrapping (stripped [1 :- 1 ], namespace )
979- return real (expr , namespace )
980-
981- monkeypatch .setattr (expressions , "_evaluate_simple_expression" , unwrapping )
982971 assert expressions ._unresolvable_term (grouped ) is None
972+
973+ # Stop the evaluator unwrapping the group and it becomes a leaf again, so
974+ # the gate goes back to reporting it as a name it cannot resolve.
975+ monkeypatch .setattr (expressions , "_is_wrapped_in_parens" , lambda text : False )
976+ assert expressions ._unresolvable_term (grouped ) is not None
0 commit comments