Skip to content

Instantly share code, notes, and snippets.

@echohack
Last active December 14, 2015 05:40
Show Gist options
  • Save echohack/5036874 to your computer and use it in GitHub Desktop.
Save echohack/5036874 to your computer and use it in GitHub Desktop.
import socket
import inject_exception2
import requests
from mock import patch
import nose.tools
# ...snippet
def test_api_call():
with patch.object(requests, "get") as get_mock:
with nose.tools.assert_raises(socket.error) and nose.tools.assert_raises(inject_exception2.ExceededRetries):
get_mock.side_effect = socket.error
inject_exception2.retry(100, call_api, "http://example.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment