Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
[project @ fetchers.Urllib2Fetcher: parameterize urlopen for #85]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Turner committed Dec 10, 2007
1 parent 56929df commit 7587170
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openid/fetchers.py
Expand Up @@ -182,6 +182,11 @@ def fetch(self, *args, **kwargs):
class Urllib2Fetcher(HTTPFetcher):
"""An C{L{HTTPFetcher}} that uses urllib2.
"""

# Parameterized for the benefit of testing frameworks, see
# http://trac.openidenabled.com/trac/ticket/85
urlopen = staticmethod(urllib2.urlopen)

def fetch(self, url, body=None, headers=None):
if not _allowedURL(url):
raise ValueError('Bad URL scheme: %r' % (url,))
Expand All @@ -195,7 +200,7 @@ def fetch(self, url, body=None, headers=None):

req = urllib2.Request(url, data=body, headers=headers)
try:
f = urllib2.urlopen(req)
f = self.urlopen(req)
try:
return self._makeResponse(f)
finally:
Expand Down

0 comments on commit 7587170

Please sign in to comment.