test_urllib2.py 文件源码

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

项目:deb-python-httpretty 作者: openstack 项目源码 文件源码
def test_httpretty_should_allow_registering_regexes():
    "HTTPretty should allow registering regexes with urllib2"

    HTTPretty.register_uri(
        HTTPretty.GET,
        re.compile("https://api.yipit.com/v1/deal;brand=(?P<brand_name>\w+)"),
        body="Found brand",
    )

    request = urllib2.Request(
        "https://api.yipit.com/v1/deal;brand=GAP",
    )
    fd = urllib2.urlopen(request)
    got = fd.read()
    fd.close()

    expect(got).to.equal(b"Found brand")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号