Created
May 27, 2012 18:48
-
-
Save riquellopes/2815470 to your computer and use it in GitHub Desktop.
Simple mock urllib2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mock import Mock | |
class MockUrlLib(Mock): | |
def __init__(self, _file, _type='html', code=200, msg='OK', headers={'content-type': 'text/plain; charset=utf-8'}): | |
self.file_test = ("%s.%s" % (_file, _type)) | |
self.code = code | |
self.msg = msg | |
self.headers = headers | |
def read(self): | |
handle = open(self.file_test) | |
html = "".join( handle ) | |
return html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment