• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testingutils.autospec_method函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.testingutils.autospec_method函数的典型用法代码示例。如果您正苦于以下问题:Python autospec_method函数的具体用法?Python autospec_method怎么用?Python autospec_method使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_do_start_some_failed

    def test_do_start_some_failed(self):
        returns = [True, None]
        autospec_method(self.job_run._start_action_runs, return_value=returns)

        assert self.job_run._do_start()
        assert_equal(self.job_run.event.ok.call_count, 1)
        self.job_run.event.ok.assert_called_with('started')
开发者ID:ContextLogic,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例2: test_cancel_pending

 def test_cancel_pending(self):
     pending_runs = [mock.Mock() for _ in xrange(2)]
     autospec_method(self.run_collection.get_pending,
         return_value=pending_runs)
     self.run_collection.cancel_pending()
     for pending_run in pending_runs:
         pending_run.cancel.assert_called_with()
开发者ID:ContextLogic,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例3: test_load_config

 def test_load_config(self):
     autospec_method(self.mcp.apply_config)
     self.mcp.config = mock.create_autospec(manager.ConfigManager)
     self.mcp._load_config()
     self.mcp.state_watcher.disabled.assert_called_with()
     self.mcp.apply_config.assert_called_with(
         self.mcp.config.load.return_value, reconfigure=False)
开发者ID:Codeacious,项目名称:Tron,代码行数:7,代码来源:mcp_test.py


示例4: test_start_no_startable_action_runs

    def test_start_no_startable_action_runs(self):
        autospec_method(self.job_run._do_start)
        self.job_run.action_runs.has_startable_action_runs = False

        assert not self.job_run.start()
        self.job_run.event.info.assert_called_with('start')
        assert not self.job_run.event.ok.mock_calls
开发者ID:ContextLogic,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例5: test_handle_action_exit_up

 def test_handle_action_exit_up(self):
     self.task.action = mock.create_autospec(ActionCommand)
     self.task.action.is_failed = False
     autospec_method(self.task.queue)
     self.task._handle_action_exit()
     self.task.notify.assert_called_with(self.task.NOTIFY_UP)
     self.task.queue.assert_called_with()
开发者ID:Feriority,项目名称:Tron,代码行数:7,代码来源:serviceinstance_test.py


示例6: setup_task

 def setup_task(self):
     self.node = mock.create_autospec(node.Node)
     self.pid_filename = '/tmp/filename'
     self.task = serviceinstance.ServiceInstanceStopTask(
         'id', self.node, self.pid_filename)
     autospec_method(self.task.watch)
     autospec_method(self.task.notify)
开发者ID:Feriority,项目名称:Tron,代码行数:7,代码来源:serviceinstance_test.py


示例7: test_read_config_no_header

 def test_read_config_no_header(self):
     name = 'some_name'
     autospec_method(self.controller._get_config_content)
     autospec_method(self.controller.render_template)
     resp = self.controller.read_config(name, add_header=False)
     assert not self.controller.render_template.called
     assert_equal(resp['config'], self.controller._get_config_content.return_value)
开发者ID:Codeacious,项目名称:Tron,代码行数:7,代码来源:controller_test.py


示例8: test_validate_fragment

 def test_validate_fragment(self):
     autospec_method(self.manager.load)
     name = 'the_name'
     self.manager.validate_fragment(name, self.content)
     container = self.manager.load.return_value
     container.add.assert_called_with(name, self.content)
     container.validate.assert_called_with()
开发者ID:strategist922,项目名称:Tron,代码行数:7,代码来源:manager_test.py


示例9: test_handle_instance_state_change_starting

 def test_handle_instance_state_change_starting(self):
     autospec_method(self.service.notify)
     autospec_method(self.service.record_events)
     instance_event = serviceinstance.ServiceInstance.STATE_STARTING
     self.service._handle_instance_state_change(mock.Mock(), instance_event)
     assert not self.service.notify.mock_calls
     assert not self.service.record_events.mock_calls
开发者ID:Codeacious,项目名称:Tron,代码行数:7,代码来源:service_test.py


示例10: test_stop

 def test_stop(self):
     autospec_method(self.node._fail_run)
     action_command = mock.create_autospec(actioncommand.ActionCommand,
         id=mock.Mock())
     self.node.run_states[action_command.id] = mock.Mock()
     self.node.stop(action_command)
     assert_equal(self.node._fail_run.call_count, 1)
开发者ID:Web5design,项目名称:Tron,代码行数:7,代码来源:node_test.py


示例11: test_handle_action_unknown

 def test_handle_action_unknown(self):
     self.task.action = mock.create_autospec(ActionCommand)
     self.task.action.is_unknown = True
     autospec_method(self.task.queue)
     self.task._handle_action_exit()
     self.task.notify.assert_called_with(self.task.NOTIFY_FAILED)
     assert_equal(self.task.queue.call_count, 1)
开发者ID:ContextLogic,项目名称:Tron,代码行数:7,代码来源:serviceinstance_test.py


示例12: test_handle_instance_state_change_failed

 def test_handle_instance_state_change_failed(self):
     autospec_method(self.service.notify)
     autospec_method(self.service.record_events)
     instance_event = serviceinstance.ServiceInstance.STATE_FAILED
     self.service._handle_instance_state_change(mock.Mock(), instance_event)
     assert not self.service.notify.mock_calls
     self.service.record_events.assert_called_with()
开发者ID:Codeacious,项目名称:Tron,代码行数:7,代码来源:service_test.py


示例13: test_handler_action_run_skipped

 def test_handler_action_run_skipped(self):
     self.action_run.is_broken = False
     self.action_run.is_skipped = True
     self.job_run.action_runs.is_scheduled = True
     autospec_method(self.job_run._start_action_runs)
     self.job_run.handler(self.action_run, mock.Mock())
     assert not self.job_run._start_action_runs.mock_calls
开发者ID:pombredanne,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例14: test_handler_finished_with_cleanup_done

 def test_handler_finished_with_cleanup_done(self):
     self.job_run.action_runs.is_active = False
     self.job_run.action_runs.is_scheduled = False
     self.job_run.action_runs.cleanup_action_run = mock.Mock(is_done=True)
     autospec_method(self.job_run.finalize)
     self.job_run.handler(self.action_run, mock.Mock())
     self.job_run.finalize.assert_called_with()
开发者ID:pombredanne,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例15: test_handler_not_end_state_event

 def test_handler_not_end_state_event(self):
     autospec_method(self.job_run.finalize)
     autospec_method(self.job_run._start_action_runs)
     self.action_run.is_done = False
     self.job_run.handler(self.action_run, mock.Mock())
     assert not self.job_run.finalize.mock_calls
     assert not self.job_run._start_action_runs.mock_calls
开发者ID:pombredanne,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例16: test_build_stop_action_command

 def test_build_stop_action_command(self):
     id, command = 'id', 'do a thing'
     autospec_method(self.factory.build_command)
     action_command = self.factory.build_stop_action_command(id, command)
     assert_equal(action_command.id,
         '%s.%s' % (id, self.factory.build_command.return_value))
     assert_equal(action_command.command,
         self.factory.build_command.return_value)
开发者ID:jabadie-iseatz,项目名称:Tron,代码行数:8,代码来源:actioncommand_test.py


示例17: test_connnectionSecure

 def test_connnectionSecure(self):
     self.transport.connection_defer = mock.Mock()
     autospec_method(self.transport.requestService)
     self.transport.connectionSecure()
     conn = self.transport.connection_defer.mock_calls[0][1][0]
     assert isinstance(conn, ssh.ClientConnection)
     auth_service  = self.transport.requestService.mock_calls[0][1][0]
     assert isinstance(auth_service, ssh.NoPasswordAuthClient)
开发者ID:Codeacious,项目名称:Tron,代码行数:8,代码来源:ssh_test.py


示例18: test_replace

 def test_replace(self):
     autospec_method(self.collection.add)
     item = mock.Mock()
     self.collection.replace(item)
     self.collection.add.assert_called_with(
         item,
         self.collection.remove_item,
     )
开发者ID:Yelp,项目名称:Tron,代码行数:8,代码来源:collections_test.py


示例19: test_write

 def test_write(self, mock_yaml, mock_open):
     command, proc = 'do this', mock.Mock()
     autospec_method(self.status_file.get_content)
     self.status_file.write(command, proc)
     self.status_file.get_content.assert_called_with(command, proc)
     mock_yaml.dump.assert_called_with(
         self.status_file.get_content.return_value,
         mock_open.return_value.__enter__.return_value)
开发者ID:Codeacious,项目名称:Tron,代码行数:8,代码来源:action_runner_test.py


示例20: test_is_done_true_because_blocked

 def test_is_done_true_because_blocked(self):
     self.run_map['action_name'].machine.state = ActionRun.STATE_FAILED
     self.run_map['second_name'].machine.state = ActionRun.STATE_QUEUED
     autospec_method(self.collection._is_run_blocked)
     blocked_second_action_run = lambda ar: ar == self.run_map['second_name']
     self.collection._is_run_blocked.side_effect = blocked_second_action_run
     assert self.collection.is_done
     assert self.collection.is_failed
开发者ID:Codeacious,项目名称:Tron,代码行数:8,代码来源:actionrun_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python server.Server类代码示例发布时间:2022-05-27
下一篇:
Python testing_utils.generate_game_for函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap