예제 #1
0
    def test_attach_maintains_priority_based_order(self):
        d = Dispatcher()
        d.attach('test', 'b', 20)
        d.attach('test', 'a', 10)
        d.attach('test', 'c', 20)

        l = d.get_listeners('test')
        self.assertEqual('a', next(l))
        self.assertEqual('b', next(l))
        self.assertEqual('c', next(l))
예제 #2
0
 def test_get_listeners_always_returns_iterator(self):
     d = Dispatcher()
     d.attach('test', 'b')
     self.assertEqual(1, sum([1 for i in d.get_listeners('test')]))
     self.assertEqual(0, sum([1 for i in d.get_listeners('unknown')]))