Skip to content

Instantly share code, notes, and snippets.

@memee
Created April 26, 2012 19:20
Show Gist options
  • Save memee/2502244 to your computer and use it in GitHub Desktop.
Save memee/2502244 to your computer and use it in GitHub Desktop.
URLError
@patch('urllib2.urlopen')
def test_api_handles_url_error(self, MockClass):
"""
usually raised where there's no connection to the host
system should inform enduser and admin
"""
import urllib2
from imei.nokia.api import IrishGsmApi as Api
MockClass.return_value.side_effect = urllib2.URLError('The server couldn\'t fulfill the request.')
api = Api()
check_info = api.get_phone_info('353511021287981')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment