def test_get_state_enumerates_state(self): a = Tracker(states) a.set_state('foo', sentinel_a) a.set_state('foo', sentinel_b) l = list(a.get_state('foo')) self.assertEqual( {(sentinel_a, None), (sentinel_b, None)}, set(l) )
def test_get_invalid(self): a = Tracker(states) with self.assertRaises(UnknownState): a.get_state('flurb', sentinel_a)
def test_set_get_value(self): data = object() a = Tracker(states) a.set_state('foo', sentinel_a, data) v = a.get_state('foo', sentinel_a) self.assertIs(data, v)