Created
June 20, 2020 18:17
-
-
Save JoshM1994/1eae6f090f6add2410b01247cba33852 to your computer and use it in GitHub Desktop.
Mock calls to asyncio.create_subprocess_shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Used to mock calls to asyncio.create_subprocess_shell | |
# Patches the `communicate` object with a future as specified during construction | |
import asynctest | |
import mock | |
class AsyncioCreateSubprocessShellCommunicateMock: | |
def __init__(self, future_result): | |
process_mock = mock.Mock() | |
future = asynctest.asyncio.Future() | |
future.set_result(future_result) | |
attrs = {"communicate.return_value": future} | |
process_mock.configure_mock(**attrs) | |
self.mock = process_mock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment