Skip to content

Commit

Permalink
test: Correct nested expr equivalence
Browse files Browse the repository at this point in the history
Spotted while investigating #3616 (comment)

When I originally wrote this test, I didn't realise I was comparing:
```py
GetAttrExpression(Parameter.name, "expr") == GetAttrExpression(Parameter.name, "expr")
```

The intention was to compare the contents were the same.

Due to `OperatorMixin.__eq__`, the previous assertion would always return `True`.
  • Loading branch information
dangotbanned committed Oct 2, 2024
1 parent cabf1e6 commit 7cfb4e0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/vegalite/v5/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def test_when_labels_position_based_on_condition() -> None:
expr=alt.expr.if_(param_width_lt_200, "red", "black")
)
when = (
alt.when(param_width_lt_200)
alt.when(param_width_lt_200.expr)
.then(alt.value("red"))
.otherwise(alt.value("black"))
)
Expand All @@ -560,7 +560,11 @@ def test_when_labels_position_based_on_condition() -> None:
param_color_py_when = alt.param(
expr=alt.expr.if_(cond["test"], cond["value"], otherwise)
)
assert param_color_py_expr.expr == param_color_py_when.expr
lhs_param = param_color_py_expr.param
rhs_param = param_color_py_when.param
assert isinstance(lhs_param, alt.VariableParameter)
assert isinstance(rhs_param, alt.VariableParameter)
assert repr(lhs_param.expr) == repr(rhs_param.expr)

chart = (
alt.Chart(df)
Expand Down

0 comments on commit 7cfb4e0

Please sign in to comment.