def test_conditional_computed_vars():
    """Test that computed vars can have conditionals."""

    class MainState(BaseState):
        flag: bool = False
        t1: str = "a"
        t2: str = "b"

        @computed_var
        def rendered_var(self) -> str:
            if self.flag:
                return self.t1
            return self.t2

    ms = MainState()
    # Initially there are no dirty computed vars.
    assert ms._dirty_computed_vars(from_vars={"flag"}) == {
        (MainState.get_full_name(), "rendered_var")
    }
    assert ms._dirty_computed_vars(from_vars={"t2"}) == {
        (MainState.get_full_name(), "rendered_var")
    }
    assert ms._dirty_computed_vars(from_vars={"t1"}) == {
        (MainState.get_full_name(), "rendered_var")
    }
    assert ms.computed_vars["rendered_var"]._deps(objclass=MainState) == {
        MainState.get_full_name(): {"flag", "t1", "t2"}
    }
Test that computed vars can have conditionals.
tests/units/test_state.py