def test_group_disconnect(self): """EmitterGroup.disconnect""" grp = EmitterGroup(em1=Event) assert len(grp.em1.callbacks) == 0, grp.em1.callbacks grp.connect(self.record_event) assert len(grp.em1.callbacks) == 1 grp.add(em2=Event) assert len(grp.em2.callbacks) == 1 grp.disconnect() assert len(grp.em1.callbacks) == 0 assert len(grp.em2.callbacks) == 0
def test_group_block(self): """EmitterGroup.block_all""" grp = EmitterGroup(em1=Event, em2=Event) def cb(ev): self.result = 1 grp.em1.connect(self.record_event) grp.em2.connect(self.record_event) grp.connect(cb) self.result = None grp.block_all() try: grp.em1() grp.em2() grp(type='test_event') finally: grp.unblock_all() assert self.result is None
def test_group_connect(self): grp = EmitterGroup(source=self, em1=Event) grp.connect(self.record_event) self.result = None ev = grp.em1(test_key=1) self.assert_result(event=ev, source=self, sources=[self, self], test_key=1)