my_opener = urllib.request.build_opener(MyHTTPHandler)
urllib.request.install_opener(my_opener)
response = urllib.request.urlopen('http://example.com')
print(response.read())
print(response.code)
print(response.msg)
How do I unit test a module that relies on urllib2?