def test_run_command_interactively(self):
file_path = os.path.join(tempfile.gettempdir(), 'test_interactive.txt')
with open(file_path, 'wr') as ff:
ff.write('Some text')
context = self.execute_module_step(
'run_command_interactively',
kwargs={
'command': 'rm -i %s' % file_path,
}
)
# file should not be removed yet
assert_that(os.path.isfile(file_path), equal_to(True))
# let's communicate and say Yes
context.command_response['child'].sendline('Y')
context.command_response['child'].expect(pexpect.EOF)
# file should be removed
assert_that(os.path.isfile(file_path), equal_to(False))
评论列表
文章目录