def test_names(self): s1 = State() s1.name = 'asd' s2 = State() assert not s1 == s2 s2.name = 'asd' assert s1 == s2
def test_all_attribs(self): par1 = State() par1.name = 'parent' par2 = State() par2.name = 'parent' assert par1 == par2 # lambdas must be same instance action = lambda a, b: a + b s1 = State() s1.name = 'name' s1.parent = par1 s1.kind = 'leaf' s1.on_enter = action s1.on_exit = action s2 = State() assert not s1 == s2 s2.name = 'name' assert not s1 == s2 s2.parent = par1 assert not s1 == s2 s2.kind = 'leaf' assert not s1 == s2 s2.on_enter = action assert not s1 == s2 s2.on_exit = action assert s1 == s2 # now it's same
def get_state(kind, name, states): st = State(states) st.name = name st.kind = kind return st