Skip to content

Instantly share code, notes, and snippets.

@lbjay
Created October 9, 2013 17:13
Show Gist options
  • Save lbjay/6904760 to your computer and use it in GitHub Desktop.
Save lbjay/6904760 to your computer and use it in GitHub Desktop.
@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