本文整理匯總了Python中aiohttp.signals.Signal.send方法的典型用法代碼示例。如果您正苦於以下問題:Python Signal.send方法的具體用法?Python Signal.send怎麽用?Python Signal.send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類aiohttp.signals.Signal
的用法示例。
在下文中一共展示了Signal.send方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_non_coroutine
# 需要導入模塊: from aiohttp.signals import Signal [as 別名]
# 或者: from aiohttp.signals.Signal import send [as 別名]
def test_non_coroutine(app):
signal = Signal(app)
kwargs = {'foo': 1, 'bar': 2}
callback = mock.Mock()
signal.append(callback)
yield from signal.send(**kwargs)
callback.assert_called_once_with(**kwargs)
示例2: test_non_coroutine
# 需要導入模塊: from aiohttp.signals import Signal [as 別名]
# 或者: from aiohttp.signals.Signal import send [as 別名]
def test_non_coroutine(loop, app):
signal = Signal(app)
kwargs = {'foo': 1, 'bar': 2}
callback = mock.Mock()
signal.append(callback)
loop.run_until_complete(signal.send(**kwargs))
callback.assert_called_once_with(**kwargs)
示例3: test_function_signal_dispatch
# 需要導入模塊: from aiohttp.signals import Signal [as 別名]
# 或者: from aiohttp.signals.Signal import send [as 別名]
def test_function_signal_dispatch(app):
signal = Signal(app)
kwargs = {'foo': 1, 'bar': 2}
callback_mock = mock.Mock()
@asyncio.coroutine
def callback(**kwargs):
callback_mock(**kwargs)
signal.append(callback)
yield from signal.send(**kwargs)
callback_mock.assert_called_once_with(**kwargs)
示例4: test_function_signal_dispatch
# 需要導入模塊: from aiohttp.signals import Signal [as 別名]
# 或者: from aiohttp.signals.Signal import send [as 別名]
def test_function_signal_dispatch(loop, app):
signal = Signal(app)
kwargs = {'foo': 1, 'bar': 2}
callback_mock = mock.Mock()
@asyncio.coroutine
def callback(**kwargs):
callback_mock(**kwargs)
signal.append(callback)
loop.run_until_complete(signal.send(**kwargs))
callback_mock.assert_called_once_with(**kwargs)
示例5: test_function_signal_dispatch2
# 需要導入模塊: from aiohttp.signals import Signal [as 別名]
# 或者: from aiohttp.signals.Signal import send [as 別名]
def test_function_signal_dispatch2(loop, app):
signal = Signal(app)
args = {"a", "b"}
kwargs = {"foo": 1, "bar": 2}
callback_mock = mock.Mock()
@asyncio.coroutine
def callback(*args, **kwargs):
callback_mock(*args, **kwargs)
signal.append(callback)
loop.run_until_complete(signal.send(*args, **kwargs))
callback_mock.assert_called_once_with(*args, **kwargs)
示例6: test_debug_signal
# 需要導入模塊: from aiohttp.signals import Signal [as 別名]
# 或者: from aiohttp.signals.Signal import send [as 別名]
def test_debug_signal(debug_app):
assert debug_app.debug, "Should be True"
signal = Signal(debug_app)
callback = mock.Mock()
pre = mock.Mock()
post = mock.Mock()
signal.append(callback)
debug_app.on_pre_signal.append(pre)
debug_app.on_post_signal.append(post)
yield from signal.send(1, a=2)
callback.assert_called_once_with(1, a=2)
pre.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
post.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
示例7: test_debug_signal
# 需要導入模塊: from aiohttp.signals import Signal [as 別名]
# 或者: from aiohttp.signals.Signal import send [as 別名]
def test_debug_signal(loop, debug_app):
assert debug_app.debug, "Should be True"
signal = Signal(debug_app)
callback = mock.Mock()
pre = mock.Mock()
post = mock.Mock()
signal.append(callback)
debug_app.on_pre_signal.append(pre)
debug_app.on_post_signal.append(post)
loop.run_until_complete(signal.send(1, a=2))
callback.assert_called_once_with(1, a=2)
pre.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
post.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)