test_requests.py 文件源码

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

项目:deb-python-httpretty 作者: openstack 项目源码 文件源码
def test_httpretty_allows_to_chose_if_querystring_should_be_matched():
    "HTTPretty should provide a way to not match regexes that have a different querystring"

    HTTPretty.register_uri(
        HTTPretty.GET,
        re.compile("https://example.org/(?P<endpoint>\w+)/$"),
        body="Nudge, nudge, wink, wink. Know what I mean?",
        match_querystring=True
    )

    response = requests.get('https://example.org/what/')
    expect(response.text).to.equal('Nudge, nudge, wink, wink. Know what I mean?')
    try:
        requests.get('https://example.org/what/?flying=coconuts')
        raised = False
    except requests.ConnectionError:
        raised = True

    assert raised is True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号