Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
def signal(self, monkeypatch):
s = Namespace().signal
monkeypatch.setattr("fiaas_deploy_daemon.crd.status.signal", s)
yield s
def test_named_blinker():
sig = blinker.NamedSignal('squiznart')
assert 'squiznart' in repr(sig)
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)
def teardown():
# Disconnect any triggers
for receiver in trigger_event.receivers_for(ANY):
trigger_event.disconnect(receiver)
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)
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()
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,
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)