Beispiel #1
0
    def test_handler_garbage_collection_2 (self):
        test   = NotifyTestObject ()
        signal = Signal ()

        handler = HandlerGarbageCollectionTestCase.HandlerObject (test)

        signal.connect (lambda *ignored: signal.stop_emission ())
        signal.connect (handler.simple_handler)

        self.assertEqual (len (signal._handlers), 2)

        signal.emit (1)

        del handler
        self.collect_garbage ()

        self.assertEqual (len (signal._handlers), 2)

        signal.emit (2)

        # Even though emission is stopped by the first handler, signal must still notice
        # that it should remove the second one.
        self.assertEqual (len (signal._handlers), 1)
        test.assert_results ()
Beispiel #2
0
    def test_handler_garbage_collection_2(self):
        test = NotifyTestObject()
        signal = Signal()

        handler = HandlerGarbageCollectionTestCase.HandlerObject(test)

        signal.connect(lambda *ignored: signal.stop_emission())
        signal.connect(handler.simple_handler)

        self.assertEqual(len(signal._handlers), 2)

        signal.emit(1)

        del handler
        self.collect_garbage()

        self.assertEqual(len(signal._handlers), 2)

        signal.emit(2)

        # Even though emission is stopped by the first handler, signal must still notice
        # that it should remove the second one.
        self.assertEqual(len(signal._handlers), 1)
        test.assert_results()