當前位置: 首頁>>代碼示例>>Python>>正文


Python Signal.freeze方法代碼示例

本文整理匯總了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]
開發者ID:Eyepea,項目名稱:aiohttp,代碼行數:11,代碼來源:test_signals.py

示例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]
開發者ID:Eyepea,項目名稱:aiohttp,代碼行數:12,代碼來源:test_signals.py

示例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]
開發者ID:KazuCocoa,項目名稱:aiohttp,代碼行數:12,代碼來源:test_signals.py

示例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)
開發者ID:KazuCocoa,項目名稱:aiohttp,代碼行數:13,代碼來源:test_signals.py

示例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)
開發者ID:KazuCocoa,項目名稱:aiohttp,代碼行數:16,代碼來源:test_signals.py


注:本文中的aiohttp.signals.Signal.freeze方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。