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


Python asynctest.ANY属性代码示例

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


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

示例1: test_ok_with_env

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_ok_with_env(self):

        input_ok = ConfigNode('test', {
            'command': 'aws-iam-authenticator token -i dummy',
            'apiVersion': 'client.authentication.k8s.io/v1beta1',
            'env': [{'name': 'EXEC_PROVIDER_ENV_NAME',
                     'value': 'EXEC_PROVIDER_ENV_VALUE'}]})

        ep = ExecProvider(input_ok)
        result = await ep.run()
        self.assertTrue(isinstance(result, dict))
        self.assertTrue('token' in result)

        env_used = self.exec_mock.await_args_list[0][1]['env']
        self.assertEqual(env_used['EXEC_PROVIDER_ENV_NAME'], 'EXEC_PROVIDER_ENV_VALUE')
        self.assertEqual(json.loads(env_used['KUBERNETES_EXEC_INFO']), {'apiVersion':
                                                                        'client.authentication.k8s.io/v1beta1',
                                                                        'kind': 'ExecCredential',
                                                                        'spec': {'interactive': sys.stdout.isatty()}})
        self.exec_mock.assert_called_once_with('aws-iam-authenticator', 'token', '-i', 'dummy',
                                               env=ANY, stderr=-1, stdin=None, stdout=-1)
        self.process_mock.stdout.read.assert_awaited_once()
        self.process_mock.stderr.read.assert_awaited_once()
        self.process_mock.wait.assert_awaited_once() 
开发者ID:tomplus,项目名称:kubernetes_asyncio,代码行数:26,代码来源:exec_provider_test.py

示例2: test_plugins

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_plugins(self):
        self = MagicMock()
        plugin1 = MagicMock()
        plugin1.pre_dummy = CoroutineMock()
        plugin1.post_dummy = CoroutineMock()
        plugin2 = MagicMock()
        plugin2.pre_dummy = CoroutineMock()
        plugin2.post_dummy = CoroutineMock()
        self.plugins = [plugin1, plugin2]

        @API.plugins
        async def dummy(self, *args, **kwargs):
            return True

        assert await dummy(self) is True
        plugin1.pre_dummy.assert_called_with(self)
        plugin1.post_dummy.assert_called_with(self, took=ANY, ret=True)
        plugin2.pre_dummy.assert_called_with(self)
        plugin2.post_dummy.assert_called_with(self, took=ANY, ret=True) 
开发者ID:argaen,项目名称:aiocache,代码行数:21,代码来源:test_base.py

示例3: test_connects_with_correct_args

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_connects_with_correct_args(self):

        await self.connection._connect()

        self.assertEqual(
            self._connect.call_args_list,
            [
                call(
                    host=self.conn_params["host"],
                    password=self.conn_params["password"],
                    virtualhost=self.conn_params["virtual_host"],
                    login=self.conn_params["username"],
                    on_error=self.connection._on_error,
                    loop=ANY,
                    heartbeat=self.conn_params["heartbeat"],
                )
            ],
        ) 
开发者ID:b2wdigital,项目名称:async-worker,代码行数:20,代码来源:test_connection.py

示例4: test_close_connection_in_state_closing_do_not_performs_abort

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_close_connection_in_state_closing_do_not_performs_abort(connection):
    connection.abort = asynctest.CoroutineMock()
    connection.closing = True

    await connection.close(asynctest.ANY)

    connection.abort.assert_not_awaited() 
开发者ID:micro-fan,项目名称:aiozk,代码行数:9,代码来源:test_connection.py

示例5: test_close_cancels_read_loop_task

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_close_cancels_read_loop_task(connection):
    connection.start_read_loop()
    connection.read_response = asynctest.CoroutineMock(return_value=(0, asynctest.ANY, asynctest.ANY))

    task_cancelled_future = connection.loop.create_future()

    def set_result(task):
        task_cancelled_future.set_result(task.cancelled())

    connection.read_loop_task.add_done_callback(set_result)

    await connection.close(asynctest.ANY)
    assert await task_cancelled_future 
开发者ID:micro-fan,项目名称:aiozk,代码行数:15,代码来源:test_connection.py

示例6: test_ok_01

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_ok_01(self):
        ep = ExecProvider(self.input_ok)
        result = await ep.run()
        self.assertTrue(isinstance(result, dict))
        self.assertTrue('token' in result)
        self.exec_mock.assert_called_once_with('aws-iam-authenticator', 'token', '-i', 'dummy',
                                               env=ANY, stderr=-1, stdin=None, stdout=-1)
        self.process_mock.stdout.read.assert_awaited_once()
        self.process_mock.stderr.read.assert_awaited_once()
        self.process_mock.wait.assert_awaited_once() 
开发者ID:tomplus,项目名称:kubernetes_asyncio,代码行数:12,代码来源:exec_provider_test.py

示例7: test_ok_with_args

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_ok_with_args(self):
        input_ok = ConfigNode('test', {
            'command': 'aws-iam-authenticator token -i dummy',
            'apiVersion': 'client.authentication.k8s.io/v1beta1',
            'args': ['--mock', '90']
        })
        ep = ExecProvider(input_ok)
        result = await ep.run()
        self.assertTrue(isinstance(result, dict))
        self.assertTrue('token' in result)
        self.exec_mock.assert_called_once_with('aws-iam-authenticator', 'token', '-i', 'dummy', '--mock', '90',
                                               env=ANY, stderr=-1, stdin=None, stdout=-1)
        self.process_mock.stdout.read.assert_awaited_once()
        self.process_mock.stderr.read.assert_awaited_once()
        self.process_mock.wait.assert_awaited_once() 
开发者ID:tomplus,项目名称:kubernetes_asyncio,代码行数:17,代码来源:exec_provider_test.py

示例8: test_find_caller_without_stack_info

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_find_caller_without_stack_info(self):
        logger = Logger()

        def caller_function():
            def log_function():
                def make_log_task():
                    return logger.find_caller()

                return make_log_task()

            return log_function()

        caller = caller_function()
        self.assertEqual(caller, (__file__, ANY, "caller_function", None)) 
开发者ID:b2wdigital,项目名称:aiologger,代码行数:16,代码来源:test_logger.py

示例9: test_calls_fn_multi_set_when_multi_get_none

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_calls_fn_multi_set_when_multi_get_none(self, mocker, decorator, decorator_call):
        mocker.spy(decorator, "get_from_cache")
        mocker.spy(decorator, "set_in_cache")
        decorator.cache.multi_get = CoroutineMock(return_value=[None, None])

        ret = await decorator_call(1, keys=["a", "b"], value="value")

        decorator.get_from_cache.assert_called_once_with("a", "b")
        decorator.set_in_cache.assert_called_with(ret, stub_dict, ANY, ANY)
        stub_dict.assert_called_once_with(1, keys=["a", "b"], value="value") 
开发者ID:argaen,项目名称:aiocache,代码行数:12,代码来源:test_decorators.py

示例10: test_cache_write_doesnt_wait_for_future

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_cache_write_doesnt_wait_for_future(self, decorator, decorator_call):
        decorator.get_from_cache = CoroutineMock(return_value=[None, None])
        decorator.set_in_cache = CoroutineMock()

        with patch("aiocache.decorators.asyncio.ensure_future"):
            await decorator_call(1, keys=["a", "b"], value="value", aiocache_wait_for_write=False)

        decorator.set_in_cache.assert_not_awaited()
        decorator.set_in_cache.assert_called_once_with({"a": ANY, "b": ANY}, stub_dict, ANY, ANY) 
开发者ID:argaen,项目名称:aiocache,代码行数:11,代码来源:test_decorators.py

示例11: test_calls_fn_with_only_missing_keys

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_calls_fn_with_only_missing_keys(self, mocker, decorator, decorator_call):
        mocker.spy(decorator, "set_in_cache")
        decorator.cache.multi_get = CoroutineMock(return_value=[1, None])

        assert await decorator_call(1, keys=["a", "b"], value="value") == {"a": ANY, "b": ANY}

        decorator.set_in_cache.assert_called_once_with({"a": ANY, "b": ANY}, stub_dict, ANY, ANY)
        stub_dict.assert_called_once_with(1, keys=["b"], value="value") 
开发者ID:argaen,项目名称:aiocache,代码行数:10,代码来源:test_decorators.py

示例12: test_get

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_get(self, mock_cache):
        await mock_cache.get(pytest.KEY)

        mock_cache._get.assert_called_with(
            mock_cache._build_key(pytest.KEY), encoding=ANY, _conn=ANY
        )
        assert mock_cache.plugins[0].pre_get.call_count == 1
        assert mock_cache.plugins[0].post_get.call_count == 1 
开发者ID:argaen,项目名称:aiocache,代码行数:10,代码来源:test_base.py

示例13: test_add

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_add(self, mock_cache):
        mock_cache._exists = CoroutineMock(return_value=False)
        await mock_cache.add(pytest.KEY, "value", ttl=2)

        mock_cache._add.assert_called_with(mock_cache._build_key(pytest.KEY), ANY, ttl=2, _conn=ANY)
        assert mock_cache.plugins[0].pre_add.call_count == 1
        assert mock_cache.plugins[0].post_add.call_count == 1 
开发者ID:argaen,项目名称:aiocache,代码行数:9,代码来源:test_base.py

示例14: test_mget

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_mget(self, mock_cache):
        await mock_cache.multi_get([pytest.KEY, pytest.KEY_1])

        mock_cache._multi_get.assert_called_with(
            [mock_cache._build_key(pytest.KEY), mock_cache._build_key(pytest.KEY_1)],
            encoding=ANY,
            _conn=ANY,
        )
        assert mock_cache.plugins[0].pre_multi_get.call_count == 1
        assert mock_cache.plugins[0].post_multi_get.call_count == 1 
开发者ID:argaen,项目名称:aiocache,代码行数:12,代码来源:test_base.py

示例15: test_mset

# 需要导入模块: import asynctest [as 别名]
# 或者: from asynctest import ANY [as 别名]
def test_mset(self, mock_cache):
        await mock_cache.multi_set([[pytest.KEY, "value"], [pytest.KEY_1, "value1"]], ttl=2)

        mock_cache._multi_set.assert_called_with(
            [(mock_cache._build_key(pytest.KEY), ANY), (mock_cache._build_key(pytest.KEY_1), ANY)],
            ttl=2,
            _conn=ANY,
        )
        assert mock_cache.plugins[0].pre_multi_set.call_count == 1
        assert mock_cache.plugins[0].post_multi_set.call_count == 1 
开发者ID:argaen,项目名称:aiocache,代码行数:12,代码来源:test_base.py


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