def mock_async_subprocess(): """Get a Popen mock back.""" async_popen = MagicMock() async def communicate(input=None): """Communicate mock.""" fixture = bytes(load_fixture("alpr_stdout.txt"), "utf-8") return (fixture, None) async_popen.communicate = communicate return async_popen
def mock_async_subprocess(): """Return an async Popen mock.""" async_popen = MagicMock() async def communicate(input=None): """Communicate mock.""" stdout = bytes("/deps_dir/lib_dir", "utf-8") return (stdout, None) async_popen.communicate = communicate return async_popen
def mock_process_creator(error: bool = False): """Mock a coroutine that creates a process when yielded.""" async def communicate() -> Tuple[bytes, bytes]: """Mock a coroutine that runs a process when yielded. Returns a tuple of (stdout, stderr). """ return b"I am stdout", b"I am stderr" mock_process = MagicMock() mock_process.communicate = communicate mock_process.returncode = int(error) return mock_process