Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[project @ fetchers.Urllib2Fetcher: parameterize urlopen for #85]

  • Loading branch information...
commit 7587170275348e7c59b094e524d4415fab6f0090 1 parent 56929df
Kevin Turner authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 openid/fetchers.py
View
7 openid/fetchers.py
@@ -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,))
@@ -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:
Please sign in to comment.
Something went wrong with that request. Please try again.