Last active
December 14, 2015 03:29
-
-
Save echohack/5021130 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
import socket | |
import inject_exception | |
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): | |
get_mock.side_effect = socket.error | |
inject_exception.call_api("http://example.com") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment