test_browser.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:mechanize 作者: python-mechanize 项目源码 文件源码
def monkey_patch_httplib(self, putheader):
        def do_nothing(*args, **kwds):
            return

        def getresponse(self_):
            class Response(object):
                msg = mimetools.Message(StringIO.StringIO(""))
                status = 200
                reason = "OK"

                def read(self__, sz=-1):
                    return ""

            return Response()

        self.monkey_patch(httplib.HTTPConnection, "putheader", putheader)
        self.monkey_patch(httplib.HTTPConnection, "connect", do_nothing)
        self.monkey_patch(httplib.HTTPConnection, "send", do_nothing)
        self.monkey_patch(httplib.HTTPConnection, "close", do_nothing)
        self.monkey_patch(httplib.HTTPConnection, "getresponse", getresponse)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号