Skip to content

Commit

Permalink
add test case for no default backend var
Browse files Browse the repository at this point in the history
  • Loading branch information
masenf committed Sep 27, 2024
1 parent f782245 commit 55c07cf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/units/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3216,6 +3216,7 @@ class MixinState(State, mixin=True):

num: int = 0
_backend: int = 0
_backend_no_default: dict

@rx.var(cache=True)
def computed(self) -> str:
Expand Down Expand Up @@ -3243,11 +3244,16 @@ def test_mixin_state() -> None:
"""Test that a mixin state works correctly."""
assert "num" in UsesMixinState.base_vars
assert "num" in UsesMixinState.vars
assert UsesMixinState.backend_vars == {"_backend": 0}
assert UsesMixinState.backend_vars == {"_backend": 0, "_backend_no_default": {}}

assert "computed" in UsesMixinState.computed_vars
assert "computed" in UsesMixinState.vars

assert (
UsesMixinState(_reflex_internal_init=True)._backend_no_default # type: ignore
is not UsesMixinState.backend_vars["_backend_no_default"]
)


def test_child_mixin_state() -> None:
"""Test that mixin vars are only applied to the highest state in the hierarchy."""
Expand Down

0 comments on commit 55c07cf

Please sign in to comment.