Rehabilitate broken tests

This commit is contained in:
lash 2022-03-29 09:24:57 +00:00
parent bb87ba1e34
commit bddf335a53
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 16 additions and 10 deletions

View File

@ -150,7 +150,7 @@ class State:
self.__keys[part].append(item)
c <<= 1
self.__keys_reverse[item] = state
if self.__reverse.get(state) == None:
if self.__reverse.get(state) == None and not self.check_alias:
s = self.elements(state)
self.alias(s, state)
@ -340,7 +340,7 @@ class State:
if self.event_callback != None:
old_state = self.__keys_reverse.get(key)
self.event_callback(key, 'nonexistent', self.name(state))
self.event_callback(key, None, self.name(state))
self.__add_state_list(state, key)
if contents != None:

View File

@ -17,12 +17,15 @@ class MockCallback:
def __init__(self):
self.items = {}
self.items_from = {}
def add(self, k, v):
def add(self, k, v_from, v_to):
if self.items.get(k) == None:
self.items[k] = []
self.items[k].append(v)
self.items_from[k] = []
self.items[k].append(v_to)
self.items_from[k].append(v_from)
class TestState(unittest.TestCase):
@ -119,7 +122,7 @@ class TestState(unittest.TestCase):
states.set('abcd', states.BAR)
v = states.state('abcd')
s = states.name(v)
self.assertEqual(s, '*FOO,BAR')
self.assertEqual(s, '_FOO_BAR')
def test_peek(self):
@ -203,10 +206,10 @@ class TestState(unittest.TestCase):
states.change('abcd', states.BAZ, states.XYZZY)
events = cb.items['abcd']
self.assertEqual(len(events), 4)
self.assertEqual(events[0], states.NEW)
self.assertEqual(events[1], states.FOO)
self.assertEqual(events[2], states.XYZZY)
self.assertEqual(events[3], states.BAZ)
self.assertEqual(states.from_name(events[0]), states.NEW)
self.assertEqual(states.from_name(events[1]), states.FOO)
self.assertEqual(states.from_name(events[2]), states.XYZZY)
self.assertEqual(states.from_name(events[3]), states.BAZ)
def test_dynamic(self):
@ -216,7 +219,6 @@ class TestState(unittest.TestCase):
states.alias('baz', states.FOO | states.BAR)
def test_mask(self):
states = State(3)
states.add('foo')

View File

@ -33,6 +33,10 @@ class MockStore:
return self.v[k]
def list(self):
return list(self.v.keys())
class TestStateItems(unittest.TestCase):
def setUp(self):