예제 #1
0
파일: test_events.py 프로젝트: Tapsa/Ferris
    def testEvent(self):
        event = Event()
        called_list = []

        def test_listener(x):
            called_list.append(x)

        event += test_listener
        event(True)

        self.assertTrue(True in called_list)

        del called_list[:]

        event -= test_listener
        event.fire(True)
        self.assertTrue(True not in called_list)
    def testEvent(self):
        event = Event()
        called_list = []

        def test_listener(x):
            called_list.append(x)

        event += test_listener
        event(True)

        self.assertTrue(True in called_list)

        # test getHandlerCount
        data = event.getHandlerCount()
        self.assertEqual(1, data)

        del called_list[:]

        event -= test_listener
        event.fire(True)
        self.assertTrue(True not in called_list)

        self.assertRaises(ValueError, event.unhandle, test_listener)  # test lines 35-36
예제 #3
0
    def testEvent(self):
        event = Event()
        called_list = []

        def test_listener(x):
            called_list.append(x)

        event += test_listener
        event(True)

        self.assertTrue(True in called_list)

        # test getHandlerCount
        data = event.getHandlerCount()
        self.assertEqual(1, data)

        del called_list[:]

        event -= test_listener
        event.fire(True)
        self.assertTrue(True not in called_list)

        self.assertRaises(ValueError, event.unhandle,
                          test_listener)  # test lines 35-36