Created
October 9, 2013 17:13
-
-
Save lbjay/6904760 to your computer and use it in GitHub Desktop.
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
@contextmanager | |
def socket_send_wrapper(send_args): | |
def fake_send(*args, **kwargs): | |
send_args.append(args, kwargs) | |
mocked_send = patch("socket.send", fake_send) | |
mocked_send.start() | |
yield | |
mocked_send.stop() | |
.... then in your test... | |
send_args = [] | |
with socket_send_wrapper(send_args): | |
run your test... | |
check what got added to send_args... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment