本文整理汇总了Python中treq.testing.StubTreq.delete方法的典型用法代码示例。如果您正苦于以下问题:Python StubTreq.delete方法的具体用法?Python StubTreq.delete怎么用?Python StubTreq.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treq.testing.StubTreq
的用法示例。
在下文中一共展示了StubTreq.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_interacts_successfully_with_istub
# 需要导入模块: from treq.testing import StubTreq [as 别名]
# 或者: from treq.testing.StubTreq import delete [as 别名]
def test_interacts_successfully_with_istub(self):
"""
The :obj:`IStringResponseStubs` is passed the correct parameters with
which to evaluate the response, and the response is returned.
"""
resource = StringStubbingResource(
self._get_response_for(
(b"DELETE", "http://what/a/thing", {b"page": [b"1"]}, {b"x-header": [b"eh"]}, b"datastr"),
(418, {b"x-response": b"responseheader"}, b"response body"),
)
)
stub = StubTreq(resource)
d = stub.delete("http://what/a/thing", headers={b"x-header": b"eh"}, params={b"page": b"1"}, data=b"datastr")
resp = self.successResultOf(d)
self.assertEqual(418, resp.code)
self.assertEqual([b"responseheader"], resp.headers.getRawHeaders(b"x-response"))
self.assertEqual(b"response body", self.successResultOf(stub.content(resp)))
示例2: test_interacts_successfully_with_istub
# 需要导入模块: from treq.testing import StubTreq [as 别名]
# 或者: from treq.testing.StubTreq import delete [as 别名]
def test_interacts_successfully_with_istub(self):
"""
The :obj:`IStringResponseStubs` is passed the correct parameters with
which to evaluate the response, and the response is returned.
"""
resource = StringStubbingResource(self._get_response_for(
('DELETE', 'http://what/a/thing', {'page': ['1']},
{'x-header': ['eh']}, 'datastr'),
(418, {'x-response': 'responseheader'}, 'response body')))
stub = StubTreq(resource)
d = stub.delete('http://what/a/thing', headers={'x-header': 'eh'},
params={'page': '1'}, data='datastr')
resp = self.successResultOf(d)
self.assertEqual(418, resp.code)
self.assertEqual(['responseheader'],
resp.headers.getRawHeaders('x-response'))
self.assertEqual('response body',
self.successResultOf(stub.content(resp)))