@@ -3424,6 +3424,18 @@ class ChildUsesMixinState(UsesMixinState):
34243424 pass
34253425
34263426
3427+ class ChildMixinState (ChildUsesMixinState , mixin = True ):
3428+ """A mixin state that inherits from a concrete state that uses mixins."""
3429+
3430+ pass
3431+
3432+
3433+ class GrandchildUsesMixinState (ChildMixinState ):
3434+ """A grandchild state that uses the mixin state."""
3435+
3436+ pass
3437+
3438+
34273439def test_mixin_state () -> None :
34283440 """Test that a mixin state works correctly."""
34293441 assert "num" in UsesMixinState .base_vars
@@ -3438,6 +3450,9 @@ def test_mixin_state() -> None:
34383450 is not UsesMixinState .backend_vars ["_backend_no_default" ]
34393451 )
34403452
3453+ assert UsesMixinState .get_parent_state () == State
3454+ assert UsesMixinState .get_root_state () == State
3455+
34413456
34423457def test_child_mixin_state () -> None :
34433458 """Test that mixin vars are only applied to the highest state in the hierarchy."""
@@ -3447,6 +3462,24 @@ def test_child_mixin_state() -> None:
34473462 assert "computed" in ChildUsesMixinState .inherited_vars
34483463 assert "computed" not in ChildUsesMixinState .computed_vars
34493464
3465+ assert ChildUsesMixinState .get_parent_state () == UsesMixinState
3466+ assert ChildUsesMixinState .get_root_state () == State
3467+
3468+
3469+ def test_grandchild_mixin_state () -> None :
3470+ """Test that a mixin can inherit from a concrete state class."""
3471+ assert "num" in GrandchildUsesMixinState .inherited_vars
3472+ assert "num" not in GrandchildUsesMixinState .base_vars
3473+
3474+ assert "computed" in GrandchildUsesMixinState .inherited_vars
3475+ assert "computed" not in GrandchildUsesMixinState .computed_vars
3476+
3477+ assert ChildMixinState .get_parent_state () == ChildUsesMixinState
3478+ assert ChildMixinState .get_root_state () == State
3479+
3480+ assert GrandchildUsesMixinState .get_parent_state () == ChildUsesMixinState
3481+ assert GrandchildUsesMixinState .get_root_state () == State
3482+
34503483
34513484def test_assignment_to_undeclared_vars ():
34523485 """Test that an attribute error is thrown when undeclared vars are set."""
0 commit comments