本文整理汇总了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())
示例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())
示例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'})