From 7cfb4e0bca6b858973e333a70700d079c09468fc Mon Sep 17 00:00:00 2001 From: dangotbanned <125183946+dangotbanned@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:05:40 +0100 Subject: [PATCH] test: Correct nested `expr` equivalence Spotted while investigating https://github.com/vega/altair/issues/3616#issuecomment-2386948880 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`. --- tests/vegalite/v5/test_api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/vegalite/v5/test_api.py b/tests/vegalite/v5/test_api.py index a7d2f1c69..92ddd6da8 100644 --- a/tests/vegalite/v5/test_api.py +++ b/tests/vegalite/v5/test_api.py @@ -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")) ) @@ -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)