当前位置: 首页>>代码示例>>Python>>正文


Python Signal.append方法代码示例

本文整理汇总了Python中aiohttp.signals.Signal.append方法的典型用法代码示例。如果您正苦于以下问题:Python Signal.append方法的具体用法?Python Signal.append怎么用?Python Signal.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiohttp.signals.Signal的用法示例。


在下文中一共展示了Signal.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delitem

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [as 别名]
def test_delitem(app):
    signal = Signal(app)
    m1 = mock.Mock()
    signal.append(m1)
    assert len(signal) == 1
    del signal[0]
    assert len(signal) == 0
开发者ID:Eyepea,项目名称:aiohttp,代码行数:9,代码来源:test_signals.py

示例2: test_setitem

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [as 别名]
def test_setitem(app):
    signal = Signal(app)
    m1 = mock.Mock()
    signal.append(m1)
    assert signal[0] is m1
    m2 = mock.Mock()
    signal[0] = m2
    assert signal[0] is m2
开发者ID:Eyepea,项目名称:aiohttp,代码行数:10,代码来源:test_signals.py

示例3: test_cannot_delitem_in_frozen_signal

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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]
开发者ID:Eyepea,项目名称:aiohttp,代码行数:11,代码来源:test_signals.py

示例4: test_non_coroutine

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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)
开发者ID:Eyepea,项目名称:aiohttp,代码行数:12,代码来源:test_signals.py

示例5: test_cannot_append_to_frozen_signal

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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]
开发者ID:Eyepea,项目名称:aiohttp,代码行数:12,代码来源:test_signals.py

示例6: test_repr

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [as 别名]
async def test_repr(app) -> None:
    signal = Signal(app)

    callback = make_mocked_coro()

    signal.append(callback)

    assert re.match(r"<Signal owner=<Application .+>, frozen=False, "
                    r"\[<Mock id='\d+'>\]>",
                    repr(signal))
开发者ID:KazuCocoa,项目名称:aiohttp,代码行数:12,代码来源:test_signals.py

示例7: test_non_coroutine

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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)
开发者ID:rim99,项目名称:aiohttp,代码行数:12,代码来源:test_signals.py

示例8: test_cannot_setitem_in_frozen_signal

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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]
开发者ID:KazuCocoa,项目名称:aiohttp,代码行数:12,代码来源:test_signals.py

示例9: test_non_coroutine

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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)
开发者ID:KazuCocoa,项目名称:aiohttp,代码行数:13,代码来源:test_signals.py

示例10: test_cannot_send_non_frozen_signal

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [as 别名]
async def test_cannot_send_non_frozen_signal(app) -> None:
    signal = Signal(app)

    callback = make_mocked_coro()

    signal.append(callback)

    with pytest.raises(RuntimeError):
        await signal.send()

    assert not callback.called
开发者ID:KazuCocoa,项目名称:aiohttp,代码行数:13,代码来源:test_signals.py

示例11: test_function_signal_dispatch

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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)
开发者ID:Eyepea,项目名称:aiohttp,代码行数:16,代码来源:test_signals.py

示例12: test_function_signal_dispatch

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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)
开发者ID:rim99,项目名称:aiohttp,代码行数:16,代码来源:test_signals.py

示例13: test_function_signal_dispatch

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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)
开发者ID:KazuCocoa,项目名称:aiohttp,代码行数:16,代码来源:test_signals.py

示例14: test_function_signal_dispatch2

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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)
开发者ID:graingert,项目名称:aiohttp,代码行数:17,代码来源:test_signals.py

示例15: test_debug_signal

# 需要导入模块: from aiohttp.signals import Signal [as 别名]
# 或者: from aiohttp.signals.Signal import append [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)
开发者ID:Eyepea,项目名称:aiohttp,代码行数:18,代码来源:test_signals.py


注:本文中的aiohttp.signals.Signal.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。