本文整理汇总了Python中bladerunner.Bladerunner.run_interactive_function方法的典型用法代码示例。如果您正苦于以下问题:Python Bladerunner.run_interactive_function方法的具体用法?Python Bladerunner.run_interactive_function怎么用?Python Bladerunner.run_interactive_function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bladerunner.Bladerunner
的用法示例。
在下文中一共展示了Bladerunner.run_interactive_function方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_interactive_function_success
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import run_interactive_function [as 别名]
def test_interactive_function_success():
"""Ensure the function is called when it passes inspection."""
def good_function(session):
return session.run("who")
runner = Bladerunner()
mock_hosts = Mock()
# we need to mock out the interactive_hosts dict b/c dict.values will
# return a new object every time, making the assert_called_once_with fail
runner.interactive_hosts = mock_hosts
map_mock = patch.object(
base.ThreadPoolExecutor,
"map",
return_value=["totes fake"],
)
with patch.object(runner, "setup_interactive") as mock_setup:
with map_mock as mock_map:
res = runner.run_interactive_function(good_function, "some host")
mock_setup.assert_called_once_with("some host")
assert mock_map.call_count == 1
mock_map.assert_called_once_with(
good_function,
mock_hosts.values(),
)
assert res == ["totes fake"]
示例2: test_interactive_functions
# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import run_interactive_function [as 别名]
def test_interactive_functions(bad_interactive_function):
"""Ensure the functions are inspected as correct then run with hosts."""
runner = Bladerunner()
with pytest.raises(TypeError):
runner.run_interactive_function(bad_interactive_function)