def test_send_on_dead_ref(self):
        """Test if sending to a gc'd callback works gracefully."""
        class C:
            def foo(self, o, e):
                pass

        c = C()
        c1 = C()
        messenger.connect(c1, 'foo', c.foo)
        messenger.send(c1, 'foo')

        # Test if things behave sanely if a message was sent and one
        # of the callbacks has been gc'd.
        m = messenger.Messenger()
        l1 = len(m._signals[hash(c1)]['foo'])
        #
        del c
        messenger.send(c1, 'foo')
        #
        l2 = len(m._signals[hash(c1)]['foo'])
        # Since 'c' is gc'd this callback should have been cleared
        # out.
        self.assertEqual(l2, l1 - 1)

        # Clean up.
        messenger.disconnect(c1)
Exemple #2
0
    def test_send_on_dead_ref(self):
        """Test if sending to a gc'd callback works gracefully."""
        class C:
            def foo(self, o, e):
                pass
        c = C()
        c1 = C()
        messenger.connect(c1, 'foo', c.foo)
        messenger.send(c1, 'foo')

        # Test if things behave sanely if a message was sent and one
        # of the callbacks has been gc'd.
        m = messenger.Messenger()
        l1 = len(m._signals[hash(c1)]['foo'])
        #
        del c
        messenger.send(c1, 'foo')
        #
        l2 = len(m._signals[hash(c1)]['foo'])
        # Since 'c' is gc'd this callback should have been cleared
        # out.
        self.assertEqual(l2, l1 - 1)

        # Clean up.
        messenger.disconnect(c1)
 def send(self, *args, **kw):
     messenger.send(self, 'method', *args, **kw)
     messenger.send(self, 'function', *args, **kw)
Exemple #4
0
 def send(self, *args, **kw):
     messenger.send(self, 'method', *args, **kw)
     messenger.send(self, 'function', *args, **kw)