当前位置: 首页>>代码示例>>Python>>正文


Python Client.patch方法代码示例

本文整理汇总了Python中werkzeug.test.Client.patch方法的典型用法代码示例。如果您正苦于以下问题:Python Client.patch方法的具体用法?Python Client.patch怎么用?Python Client.patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.test.Client的用法示例。


在下文中一共展示了Client.patch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_base_request

# 需要导入模块: from werkzeug.test import Client [as 别名]
# 或者: from werkzeug.test.Client import patch [as 别名]
def test_base_request():
    client = Client(request_demo_app, RequestTestResponse)

    # get requests
    response = client.get("/?foo=bar&foo=hehe")
    strict_eq(response["args"], MultiDict([("foo", u"bar"), ("foo", u"hehe")]))
    strict_eq(response["args_as_list"], [("foo", [u"bar", u"hehe"])])
    strict_eq(response["form"], MultiDict())
    strict_eq(response["form_as_list"], [])
    strict_eq(response["data"], b"")
    assert_environ(response["environ"], "GET")

    # post requests with form data
    response = client.post(
        "/?blub=blah",
        data="foo=blub+hehe&blah=42",
        content_type="application/x-www-form-urlencoded",
    )
    strict_eq(response["args"], MultiDict([("blub", u"blah")]))
    strict_eq(response["args_as_list"], [("blub", [u"blah"])])
    strict_eq(response["form"], MultiDict([("foo", u"blub hehe"), ("blah", u"42")]))
    strict_eq(response["data"], b"")
    # currently we do not guarantee that the values are ordered correctly
    # for post data.
    # strict_eq(response['form_as_list'], [('foo', ['blub hehe']), ('blah', ['42'])])
    assert_environ(response["environ"], "POST")

    # patch requests with form data
    response = client.patch(
        "/?blub=blah",
        data="foo=blub+hehe&blah=42",
        content_type="application/x-www-form-urlencoded",
    )
    strict_eq(response["args"], MultiDict([("blub", u"blah")]))
    strict_eq(response["args_as_list"], [("blub", [u"blah"])])
    strict_eq(response["form"], MultiDict([("foo", u"blub hehe"), ("blah", u"42")]))
    strict_eq(response["data"], b"")
    assert_environ(response["environ"], "PATCH")

    # post requests with json data
    json = b'{"foo": "bar", "blub": "blah"}'
    response = client.post("/?a=b", data=json, content_type="application/json")
    strict_eq(response["data"], json)
    strict_eq(response["args"], MultiDict([("a", u"b")]))
    strict_eq(response["form"], MultiDict())
开发者ID:pallets,项目名称:werkzeug,代码行数:47,代码来源:test_wrappers.py

示例2: test_base_request

# 需要导入模块: from werkzeug.test import Client [as 别名]
# 或者: from werkzeug.test.Client import patch [as 别名]
def test_base_request():
    client = Client(request_demo_app, RequestTestResponse)

    # get requests
    response = client.get('/?foo=bar&foo=hehe')
    strict_eq(response['args'], MultiDict([('foo', u'bar'), ('foo', u'hehe')]))
    strict_eq(response['args_as_list'], [('foo', [u'bar', u'hehe'])])
    strict_eq(response['form'], MultiDict())
    strict_eq(response['form_as_list'], [])
    strict_eq(response['data'], b'')
    assert_environ(response['environ'], 'GET')

    # post requests with form data
    response = client.post('/?blub=blah', data='foo=blub+hehe&blah=42',
                           content_type='application/x-www-form-urlencoded')
    strict_eq(response['args'], MultiDict([('blub', u'blah')]))
    strict_eq(response['args_as_list'], [('blub', [u'blah'])])
    strict_eq(response['form'], MultiDict([('foo', u'blub hehe'), ('blah', u'42')]))
    strict_eq(response['data'], b'')
    # currently we do not guarantee that the values are ordered correctly
    # for post data.
    # strict_eq(response['form_as_list'], [('foo', ['blub hehe']), ('blah', ['42'])])
    assert_environ(response['environ'], 'POST')

    # patch requests with form data
    response = client.patch('/?blub=blah', data='foo=blub+hehe&blah=42',
                            content_type='application/x-www-form-urlencoded')
    strict_eq(response['args'], MultiDict([('blub', u'blah')]))
    strict_eq(response['args_as_list'], [('blub', [u'blah'])])
    strict_eq(response['form'],
              MultiDict([('foo', u'blub hehe'), ('blah', u'42')]))
    strict_eq(response['data'], b'')
    assert_environ(response['environ'], 'PATCH')

    # post requests with json data
    json = b'{"foo": "bar", "blub": "blah"}'
    response = client.post('/?a=b', data=json, content_type='application/json')
    strict_eq(response['data'], json)
    strict_eq(response['args'], MultiDict([('a', u'b')]))
    strict_eq(response['form'], MultiDict())
开发者ID:jasco,项目名称:werkzeug,代码行数:42,代码来源:test_wrappers.py

示例3: patch

# 需要导入模块: from werkzeug.test import Client [as 别名]
# 或者: from werkzeug.test.Client import patch [as 别名]
def patch(url_patch, payload, hashing=True):
    if hashing:
        url_patch = hmac_hashing(url_patch, payload)
    c = Client(app, BaseResponse)
    return c.patch(url_patch, data=json.dumps(payload), headers={'Content-Type':'application/json'})
开发者ID:daniloitj,项目名称:django-tastypie-hmacauth,代码行数:7,代码来源:tests.py


注:本文中的werkzeug.test.Client.patch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。