tests.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:cli-bdd 作者: chibisov 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号