def test_disconnect_handler(self): s = Signal() h1 = HandlerMock() h2 = HandlerMock() h3 = HandlerMock() s.connect(h1) s.connect(h2) s.fire(1) s.connect(h3) s.fire(2) s.disconnect(h1) s.fire(3) assert h1.call_counter is 2 assert h2.call_counter is 3 assert h3.call_counter is 2 assert h1.args == (2,) assert h2.args == (3,) assert h3.args == (3,)
def test_disconnect_not_connected_handler(self): s = Signal() h = HandlerMock() s.connect(h) assert s.disconnect(lambda: None) is False assert s.disconnect(h) is True