test_sharedfoldercoordinator.py 文件源码

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

项目:edi 作者: lueschem 项目源码 文件源码
def test_verify_container_mountpoints_connection_failure(config_files, monkeypatch):
    with open(config_files, "r") as main_file:
        def fake_lxc_exec_command(*popenargs, **kwargs):
            if get_command(popenargs) == 'lxc' and get_sub_command(popenargs) == 'exec':
                if get_command_parameter(popenargs, '--') == 'true':
                    cmd = ['bash', '-c', '>&2 echo -e "lxc command failed" ; exit 1']
                    return subprocess.run(cmd, **kwargs)
                else:
                    return subprocess.CompletedProcess("fakerun", 0, '')
            else:
                return subprocess.run(*popenargs, **kwargs)

        monkeypatch.setattr(mockablerun, 'run_mockable', fake_lxc_exec_command)

        parser = ConfigurationParser(main_file)

        coordinator = SharedFolderCoordinator(parser)
        with pytest.raises(FatalError) as error:
            coordinator.verify_container_mountpoints('fake-container')
        assert 'fake-container' in error.value.message
        assert 'lxc command failed' in error.value.message
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号