tests fix
This commit is contained in:
parent
07a0560145
commit
c3a2688948
@ -1282,10 +1282,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|||||||
and name not in self.vars
|
and name not in self.vars
|
||||||
and name not in self.get_skip_vars()
|
and name not in self.get_skip_vars()
|
||||||
):
|
):
|
||||||
available_vars = ", ".join(self.vars) or "None"
|
|
||||||
raise AttributeError(
|
raise AttributeError(
|
||||||
f"The state variable '{name}' has not been defined in '{type(self).__name__}'. "
|
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.
|
# Set the attribute.
|
||||||
|
@ -3277,14 +3277,11 @@ def test_assignment_to_undeclared_vars():
|
|||||||
def handle_var(self):
|
def handle_var(self):
|
||||||
self.value = 20
|
self.value = 20
|
||||||
|
|
||||||
state = State()
|
state = State() # type: ignore
|
||||||
sub_state = Substate()
|
sub_state = Substate() # type: ignore
|
||||||
|
|
||||||
with pytest.raises(AttributeError):
|
with pytest.raises(AttributeError):
|
||||||
state.handle()
|
state.handle()
|
||||||
|
|
||||||
with pytest.raises(AttributeError):
|
|
||||||
sub_state.handle()
|
|
||||||
|
|
||||||
with pytest.raises(AttributeError):
|
with pytest.raises(AttributeError):
|
||||||
sub_state.handle_var()
|
sub_state.handle_var()
|
||||||
|
Loading…
Reference in New Issue
Block a user