本文整理汇总了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)
示例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)
示例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)
示例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)