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_signal(self, livedata):
signal = livedata.signal('/foo/bar')
assert isinstance(signal, blinker.base.Signal)
def test_meta_connect_failure():
def meta_received(sender, **kw):
raise TypeError('boom')
assert not blinker.receiver_connected.receivers
blinker.receiver_connected.connect(meta_received)
def receiver(sender, **kw):
pass
sig = blinker.Signal()
assert_raises(TypeError, sig.connect, receiver)
assert not sig.receivers
assert not sig._by_receiver
assert sig._by_sender == {blinker.base.ANY_ID: set()}
blinker.receiver_connected._clear_state()
def _monkey_patch_hashable_func():
def hashable_identity(obj):
if hasattr(obj, '__func__'):
return (id(obj.__func__), id(obj.__self__))
elif hasattr(obj, 'im_func'):
return (id(obj.im_func), id(obj.im_self))
elif isinstance(obj, (str, bytes)):
return obj
# hack for session hash info
elif hasattr(obj, "info") and obj.info:
return hash(str(sorted(obj.info.items())))
else:
return id(obj)
import blinker.base
blinker.base.hashable_identity = hashable_identity
_monkey_patch_hashable_func()