utils.py 文件源码

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

项目:nimp 作者: dontnod 项目源码 文件源码
def mock_capture_process_output(*mock_commands):
    ''' Mocks calls to popen '''
    mock_dict = {}
    for it in mock_commands:
        assert isinstance(it, MockCommand)
        mock_dict[it.command] = it

    def _mock(directory, command, stdin = None, _ = True):
        assert directory is not None
        executable = command[0]
        if executable not in mock_dict:
            return (0, '', '')
        return mock_dict[executable].get_result(command[1:], stdin = stdin)

    with unittest.mock.patch('nimp.system.capture_process_output') as mock:
        with unittest.mock.patch('nimp.sys.platform.is_msys') as mock_is_msys:
            mock_is_msys.return_value = False
            mock.side_effect = _mock
            yield mock
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号