fix state reset() (#1501)

This commit is contained in:
Thomas Brandého 2023-08-02 20:02:05 +02:00 committed by GitHub
parent be617a8dc9
commit 9222bbbdf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View File

@ -632,9 +632,6 @@ class State(Base, ABC, extra=pydantic.Extra.allow):
for substate in self.substates.values():
substate.reset()
# Clean the state.
self.clean()
def get_substate(self, path: Sequence[str]) -> Optional[State]:
"""Get the substate.

View File

@ -560,12 +560,27 @@ def test_reset(test_state, child_state):
assert test_state.num2 == 3.14
assert child_state.value == ""
expected_dirty_vars = {
"num1",
"num2",
"obj",
"upper",
"complex",
"is_hydrated",
"fig",
"key",
"sum",
"array",
"map_key",
"mapping",
}
# The dirty vars should be reset.
assert test_state.dirty_vars == set()
assert child_state.dirty_vars == set()
assert test_state.dirty_vars == expected_dirty_vars
assert child_state.dirty_vars == {"count", "value"}
# The dirty substates should be reset.
assert test_state.dirty_substates == set()
assert test_state.dirty_substates == {"child_state", "child_state2"}
@pytest.mark.asyncio