How to use blinker - 10 common examples

To help you get started, we’ve selected a few blinker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jek / blinker / tests / test_saferef.py View on Github external
def test_ShortCircuit(self):
        """Test that creation short-circuits to reuse existing references"""
        sd = {}
        for s in self.ss:
            sd[s] = 1
        for t in self.ts:
            if hasattr(t, 'x'):
                assert safe_ref(t.x) in sd
            else:
                assert safe_ref(t) in sd
github jek / blinker / tests / test_saferef.py View on Github external
def test_ShortCircuit(self):
        """Test that creation short-circuits to reuse existing references"""
        sd = {}
        for s in self.ss:
            sd[s] = 1
        for t in self.ts:
            if hasattr(t, 'x'):
                assert safe_ref(t.x) in sd
            else:
                assert safe_ref(t) in sd
github fiaas / fiaas-deploy-daemon / tests / fiaas_deploy_daemon / crd / test_crd_status.py View on Github external
def signal(self, monkeypatch):
        s = Namespace().signal
        monkeypatch.setattr("fiaas_deploy_daemon.crd.status.signal", s)
        yield s
github jek / blinker / tests / test_signals.py View on Github external
def test_named_blinker():
    sig = blinker.NamedSignal('squiznart')
    assert 'squiznart' in repr(sig)
github CenterForOpenScience / osf.io / api_tests / utils.py View on Github external
def disconnected_from_listeners(signal):
    """Temporarily disconnect all listeners for a Blinker signal."""
    listeners = list(signal.receivers_for(ANY))
    for listener in listeners:
        signal.disconnect(listener)
    yield
    for listener in listeners:
        signal.connect(listener)
github hebenon / oversight / tests / test_pushover_notifier.py View on Github external
def teardown():
    # Disconnect any triggers
    for receiver in trigger_event.receivers_for(ANY):
        trigger_event.disconnect(receiver)
github hebenon / oversight / tests / test_monitor.py View on Github external
def teardown():
    # Disconnect any triggers
    for receiver in image_analysis.receivers_for(ANY):
        image_analysis.disconnect(receiver)

    for receiver in trigger_event.receivers_for(ANY):
        trigger_event.disconnect(receiver)
github jek / blinker / tests / test_signals.py View on Github external
sentinel = []
    def meta_received(sender, **kw):
        sentinel.append(dict(kw, sender=sender))

    assert not blinker.receiver_connected.receivers
    blinker.receiver_connected.connect(meta_received)
    assert not sentinel

    def receiver(sender, **kw):
        pass
    sig = blinker.Signal()
    sig.connect(receiver)

    assert sentinel == [dict(sender=sig,
                             receiver_arg=receiver,
                             sender_arg=blinker.ANY,
                             weak_arg=True)]

    blinker.receiver_connected._clear_state()
github biosustain / potion / tests / backends / peewee / test_peewee_signals.py View on Github external
    def assertSignals(self, expected_events, sender=ANY):
        events = []

        def receiver_(signal, sender, **kwargs):
            events.append((signal, sender, kwargs))

        receivers = {
            signal: partial(receiver_, signal) for signal in [
            signals.before_create,
            signals.after_create,
            signals.before_update,
            signals.after_update,
            signals.before_delete,
            signals.after_delete,
            signals.before_add_to_relation,
            signals.after_add_to_relation,
            signals.before_remove_from_relation,
github hebenon / oversight / tests / test_image_buffer.py View on Github external
def teardown():
    # Disconnect any triggers
    for receiver in image.receivers_for(ANY):
        image.disconnect(receiver)

    for receiver in image_buffer.receivers_for(ANY):
        image_buffer.disconnect(receiver)