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


Python Bladerunner._run_parallel_safely方法代码示例

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


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

示例1: test_run_safely_to_parralel

# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import _run_parallel_safely [as 别名]
def test_run_safely_to_parralel():
    """Ensure after the first success the rest are run in parallel."""

    runner = Bladerunner({
        "username": "broguy",
        "password": "hunter14",
        "progressbar": True,
        "port": 2244,
    })

    # we have to set up the progressbar ourselves here, normally it'd happen in
    # run once we know the len of servers to run on.
    runner.progress = ProgressBar(3, runner.options)

    with patch.object(runner, "connect", return_value=("ok", 0)) as p_connect:
        with patch.object(runner, "send_commands", return_value=[]) as p_send:
            with patch.object(runner, "close") as p_close:
                with patch.object(runner, "_run_parallel_no_check") as p_run:
                    with patch.object(runner.progress, "update") as p_update:
                        runner._run_parallel_safely(["1st", "2nd", "3rd"])

    p_connect.assert_called_once_with(
        "1st",
        "broguy",
        "hunter14",
        2244,
    )
    p_send.assert_called_once_with("ok", "1st")
    p_close.assert_called_once_with("ok", True)
    # if the progressbar is used we should update it once for the check run
    assert p_update.called
    p_run.assert_called_once_with(["2nd", "3rd"])
开发者ID:Demonware,项目名称:bladerunner,代码行数:34,代码来源:test_base.py

示例2: test_run_safely_to_serial

# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import _run_parallel_safely [as 别名]
def test_run_safely_to_serial():
    """Ensure we only carry on with parallel no check on good first login."""

    runner = Bladerunner({
        "username": "dudebro",
        "password": "hunter99",
        "port": 202,
    })

    with patch.object(runner, "connect", return_value=(None, -2)) as p_connect:
        with patch.object(runner, "_run_serial", return_value=[]) as p_run:
            ret = runner._run_parallel_safely(["one", "two", "three"])

    p_connect.assert_called_once_with(
        "one",
        "dudebro",
        "hunter99",
        202,
    )
    p_run.assert_called_once_with(["two", "three"])
    assert ret == [{"name": "one", "results": [("login", runner.errors[1])]}]
开发者ID:Demonware,项目名称:bladerunner,代码行数:23,代码来源:test_base.py


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