def test_delitem(app): signal = Signal(app) m1 = mock.Mock() signal.append(m1) assert len(signal) == 1 del signal[0] assert len(signal) == 0
def function2805(function1121): var1658 = Signal(function1121) var921 = mock.Mock() var1658.append(var921) assert (len(var1658) == 1) del var1658[0] assert (len(var1658) == 0)
def function2296(function1121): var2457 = Signal(function1121) var2367 = mock.Mock() var2457.append(var2367) var2457.freeze() with pytest.raises(RuntimeError): del var2457[0] assert (list(var2457) == [var2367])
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
def function1396(function1121): var3642 = Signal(function1121) var1856 = mock.Mock() var3642.append(var1856) assert (var3642[0] is var1856) var259 = mock.Mock() var3642[0] = var259 assert (var3642[0] is var259)
async def test_repr(app: Any) -> None: signal = Signal(app) callback = make_mocked_coro() signal.append(callback) assert Matches(r"<Signal owner=<Application .+>, frozen=False, " r"\[<Mock id='\d+'>\]>") == repr(signal)
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]
def function2559(function1121): var98 = Signal(function1121) var2142 = mock.Mock() var516 = mock.Mock() var98.append(var2142) var98.freeze() with pytest.raises(RuntimeError): var98[0] = var516 assert (list(var98) == [var2142])
def function2183(function1121): var4737 = Signal(function1121) var805 = mock.Mock() var3494 = mock.Mock() var4737.append(var805) var4737.freeze() with pytest.raises(RuntimeError): var4737.append(var3494) assert (list(var4737) == [var805])
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))
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]
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]
def function1362(function1121): var676 = Signal(function1121) var2961 = { 'foo': 1, 'bar': 2, } function382 = mock.Mock() var676.append(function382) yield from var676.send(None=var2961) function382.assert_called_once_with(None=var2961)
async def test_non_coroutine(app): signal = Signal(app) kwargs = {'foo': 1, 'bar': 2} callback = mock.Mock() signal.append(callback) await signal.send(**kwargs) callback.assert_called_once_with(**kwargs)
def test_cannot_setitem_in_frozen_signal(app: Any) -> 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]
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)
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)
async def test_repr(app): 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))
async def test_cannot_send_non_frozen_signal(app): signal = Signal(app) callback = make_mocked_coro() signal.append(callback) with pytest.raises(RuntimeError): await signal.send() assert not callback.called
async def test_non_coroutine(app: Any) -> 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)
async def test_non_coroutine(app): signal = Signal(app) kwargs = {'foo': 1, 'bar': 2} callback = mock.Mock() signal.append(callback) signal.freeze() with pytest.raises(TypeError): await signal.send(**kwargs)
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
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)
def function1281(function2688): assert function2688.debug, 'Should be True' var3888 = Signal(function2688) function382 = mock.Mock() var3839 = mock.Mock() var835 = mock.Mock() var3888.append(function382) function2688.on_pre_signal.append(var3839) function2688.on_post_signal.append(var835) yield from var3888.send(1, a=2) function382.assert_called_once_with(1, a=2) var3839.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2) var835.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2)
async def test_function_signal_dispatch(app): signal = Signal(app) kwargs = {'foo': 1, 'bar': 2} callback_mock = mock.Mock() async def callback(**kwargs): callback_mock(**kwargs) signal.append(callback) await signal.send(**kwargs) callback_mock.assert_called_once_with(**kwargs)
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)
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)
async def test_function_signal_dispatch(app: Any) -> 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)
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)
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)
def function105(function1121): var3164 = Signal(function1121) var96 = { 'foo': 1, 'bar': 2, } var2570 = mock.Mock() @asyncio.coroutine def function382(**kwargs): var2570(None=var96) var3164.append(function382) yield from var3164.send(None=var96) var2570.assert_called_once_with(None=var96)
async def test_function_signal_dispatch2(app) -> None: signal = Signal(app) args = {'a', 'b'} kwargs = {'foo': 1, 'bar': 2} callback_mock = mock.Mock() async def callback(*args, **kwargs): callback_mock(*args, **kwargs) signal.append(callback) signal.freeze() await signal.send(*args, **kwargs) callback_mock.assert_called_once_with(*args, **kwargs)
def function590(function1121): var906 = Signal(function1121) var730 = {'a', 'b'} var1090 = { 'foo': 1, 'bar': 2, } var852 = mock.Mock() @asyncio.coroutine def function382(*args, **kwargs): var852(*var730, None=var1090) var906.append(function382) yield from var906.send(*var730, None=var1090) var852.assert_called_once_with(*var730, None=var1090)
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)
async 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) await 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)
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)