def test_signal_is_sent(self): self.call_count = 0 def handler(**kw): self.call_count += 1 assert kw.get('instance') == self.object assert kw.get('sender') == TranslatedModel assert kw.get('field_name') == 'name' translation_saved.connect(handler) self.test_update_translation() translation_saved.disconnect(handler) assert self.call_count == 1
def test_signal_is_sent_with_dict(self): self.call_count = 0 self.handler_instance = None def handler(**kw): self.call_count += 1 assert kw.get('sender') == TranslatedModel self.handler_instance = kw.get('instance') assert kw.get('field_name') == 'name' translation_saved.connect(handler) self.test_update_with_dict() translation_saved.disconnect(handler) assert self.call_count == 3 assert self.handler_instance == self.object # Set by handler()