Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __getitem__(self, signal):
"""All captured signals are available via `ctxt[signal]`.
"""
if isinstance(signal, blinker.base.NamedSignal):
return self._records[signal]
else:
super(CaptureSignals, self).__setitem__(signal)
def __getitem__(self, signal):
"""All captured signals are available via `ctxt[signal]`.
"""
if isinstance(signal, blinker.base.NamedSignal):
return self._records[signal]
else:
super(CaptureSignals, self).__setitem__(signal)
def test_engine_initialized(self):
# given:
expected_signal_names = self.signal_names
# when:
engine = self.setup()
# then:
assert list(engine.signals.keys()) == expected_signal_names
for signal_name in expected_signal_names:
signal_obj = engine.signals[signal_name]
assert signal_obj is not None
assert isinstance(signal_obj, NamedSignal)
def trigger_sync(cls, event, sender, **kw):
"Triggers a synchronous event"
if not isinstance(event, NamedSignal):
raise RuntimeError(
"Async signals can't be triggered synchronously: %s." % event.name
)
return event.send(sender, **kw)
def signal(self, name, doc=None):
"""Return the :class:`NamedSignal` *name*, creating it if required.
Repeated calls to this function will return the same signal object.
"""
try:
return self[name]
except KeyError:
return self.setdefault(name, NamedSignal(name, doc))