Permalink
Browse files

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

  • Loading branch information...
Kevin Turner
Kevin Turner committed Dec 10, 2007
1 parent 56929df commit 7587170275348e7c59b094e524d4415fab6f0090
Showing with 6 additions and 1 deletion.
  1. +6 −1 openid/fetchers.py
View
@@ -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:

0 comments on commit 7587170

Please sign in to comment.