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
评论列表
文章目录