From c3a2688948303e43ac6d6f9b3e67687654090078 Mon Sep 17 00:00:00 2001 From: Elijah Date: Thu, 26 Sep 2024 15:04:25 +0000 Subject: [PATCH] tests fix --- reflex/state.py | 3 +-- tests/units/test_state.py | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/reflex/state.py b/reflex/state.py index 22d79120e..515370be0 100644 --- a/reflex/state.py +++ b/reflex/state.py @@ -1282,10 +1282,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow): and name not in self.vars and name not in self.get_skip_vars() ): - available_vars = ", ".join(self.vars) or "None" raise AttributeError( f"The state variable '{name}' has not been defined in '{type(self).__name__}'. " - f"All state variables must be declared before they can be set. Available vars: {available_vars}" + f"All state variables must be declared before they can be set." ) # Set the attribute. diff --git a/tests/units/test_state.py b/tests/units/test_state.py index d4ece2b81..1f5c6a70c 100644 --- a/tests/units/test_state.py +++ b/tests/units/test_state.py @@ -3277,14 +3277,11 @@ def test_assignment_to_undeclared_vars(): def handle_var(self): self.value = 20 - state = State() - sub_state = Substate() + state = State() # type: ignore + sub_state = Substate() # type: ignore with pytest.raises(AttributeError): state.handle() - with pytest.raises(AttributeError): - sub_state.handle() - with pytest.raises(AttributeError): sub_state.handle_var()