本文整理汇总了Python中aiohttp.signals.Signal.freeze方法的典型用法代码示例。如果您正苦于以下问题:Python Signal.freeze方法的具体用法?Python Signal.freeze怎么用?Python Signal.freeze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aiohttp.signals.Signal
的用法示例。
在下文中一共展示了Signal.freeze方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cannot_delitem_in_frozen_signal
# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import freeze [as 别名]
def test_cannot_delitem_in_frozen_signal(app):
signal = Signal(app)
m1 = mock.Mock()
signal.append(m1)
signal.freeze()
with pytest.raises(RuntimeError):
del signal[0]
assert list(signal) == [m1]
示例2: test_cannot_append_to_frozen_signal
# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import freeze [as 别名]
def test_cannot_append_to_frozen_signal(app):
signal = Signal(app)
m1 = mock.Mock()
m2 = mock.Mock()
signal.append(m1)
signal.freeze()
with pytest.raises(RuntimeError):
signal.append(m2)
assert list(signal) == [m1]
示例3: test_cannot_setitem_in_frozen_signal
# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import freeze [as 别名]
def test_cannot_setitem_in_frozen_signal(app) -> None:
signal = Signal(app)
m1 = mock.Mock()
m2 = mock.Mock()
signal.append(m1)
signal.freeze()
with pytest.raises(RuntimeError):
signal[0] = m2
assert list(signal) == [m1]
示例4: test_non_coroutine
# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import freeze [as 别名]
async def test_non_coroutine(app) -> None:
signal = Signal(app)
kwargs = {'foo': 1, 'bar': 2}
callback = mock.Mock()
signal.append(callback)
signal.freeze()
with pytest.raises(TypeError):
await signal.send(**kwargs)
示例5: test_function_signal_dispatch
# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import freeze [as 别名]
async def test_function_signal_dispatch(app) -> None:
signal = Signal(app)
kwargs = {'foo': 1, 'bar': 2}
callback_mock = mock.Mock()
async def callback(**kwargs):
callback_mock(**kwargs)
signal.append(callback)
signal.freeze()
await signal.send(**kwargs)
callback_mock.assert_called_once_with(**kwargs)