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


Python Bladerunner._try_for_unmatched_prompt方法代码示例

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


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

示例1: test_try_for_unmatched_works

# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import _try_for_unmatched_prompt [as 别名]
def test_try_for_unmatched_works():
    """Ensure logic when the first attempt at guessing works."""

    runner = Bladerunner()

    server = Mock()
    with patch.object(runner, "_push_expect_forward") as p_push:
        with patch.object(base, "format_output") as p_format:
            runner._try_for_unmatched_prompt(
                server,
                bytes_or_string("fake output"),
                "fake",
            )

    assert "fake\\ output" in runner.options["shell_prompts"]
    p_format.assert_called_once_with(
        bytes_or_string("fake output"),
        "fake",
        runner.options,
    )
    p_push.assert_called_once_with(server)
开发者ID:Demonware,项目名称:bladerunner,代码行数:23,代码来源:test_base.py

示例2: test_try_unmatched_works_from_login

# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import _try_for_unmatched_prompt [as 别名]
def test_try_unmatched_works_from_login():
    """When guessing prompt on login, return the server object and status."""

    runner = Bladerunner()
    server = Mock()
    with patch.object(runner, "_push_expect_forward") as p_push:
        ret = runner._try_for_unmatched_prompt(
            server,
            bytes_or_string("out"),
            "fake",
            True,
        )

    p_push.assert_called_once_with(server)
    assert ret == (server, 1)
开发者ID:Demonware,项目名称:bladerunner,代码行数:17,代码来源:test_base.py

示例3: test_try_for_unmatched_fails

# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import _try_for_unmatched_prompt [as 别名]
def test_try_for_unmatched_fails():
    """Bladerunner "hits enter" up to 3 times to try to guess the prompt."""

    runner = Bladerunner()
    server = Mock()
    server.expect = Mock(side_effect=pexpect.TIMEOUT("fake"))
    server.before = bytes_or_string("mock output")

    with patch.object(runner, "send_interrupt") as p_interrupt:
        ret = runner._try_for_unmatched_prompt(
            server,
            bytes_or_string("out"),
            "fake",
        )

    assert ret == -1
    assert "out" in runner.options["shell_prompts"]
    p_interrupt.assert_called_once_with(server)
开发者ID:Demonware,项目名称:bladerunner,代码行数:20,代码来源:test_base.py

示例4: test_try_unmatched_fails_from_login

# 需要导入模块: from bladerunner import Bladerunner [as 别名]
# 或者: from bladerunner.Bladerunner import _try_for_unmatched_prompt [as 别名]
def test_try_unmatched_fails_from_login():
    """When trying to guess on login, return None, -6 on error."""

    runner = Bladerunner()
    server = Mock()
    server.expect = Mock(side_effect=pexpect.TIMEOUT("fake"))
    server.before = bytes_or_string("mock output")

    with patch.object(runner, "send_interrupt") as p_interrupt:
        ret = runner._try_for_unmatched_prompt(
            server,
            bytes_or_string("out"),
            "fake",
            True,
        )

    assert ret == (None, -6)
    assert "out" in runner.options["shell_prompts"]
    p_interrupt.assert_called_once_with(server)
开发者ID:Demonware,项目名称:bladerunner,代码行数:21,代码来源:test_base.py


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