本文整理汇总了Python中mock.NonCallableMock.content方法的典型用法代码示例。如果您正苦于以下问题:Python NonCallableMock.content方法的具体用法?Python NonCallableMock.content怎么用?Python NonCallableMock.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.NonCallableMock
的用法示例。
在下文中一共展示了NonCallableMock.content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _mock_response
# 需要导入模块: from mock import NonCallableMock [as 别名]
# 或者: from mock.NonCallableMock import content [as 别名]
def _mock_response(self):
response = NonCallableMock()
response._headers = {}
response.status_code = 200
response.queries = []
response.get = response._headers.get
response.content = ""
return response
示例2: NonCallableMock
# 需要导入模块: from mock import NonCallableMock [as 别名]
# 或者: from mock.NonCallableMock import content [as 别名]
from __future__ import unicode_literals, absolute_import, print_function, division
import json
import requests
from requests.models import Response
from requests.structures import CaseInsensitiveDict
from mock import Mock, NonCallableMock
from core.tests.mocks.data import MOCK_DATA
ok_response = NonCallableMock(spec=Response)
ok_response.headers = CaseInsensitiveDict(data={"content-type": "application/json"})
ok_response.content = json.dumps(MOCK_DATA)
ok_response.status_code = 200
agent_response = NonCallableMock(spec=Response)
agent_response.headers = CaseInsensitiveDict(data={
"content-type": "application/json",
"user-agent": "Mozilla /5.0 (Compatible MSIE 9.0;Windows NT 6.1;WOW64; Trident/5.0)"
})
agent_response.content = json.dumps(MOCK_DATA)
agent_response.status_code = 200
not_found_response = NonCallableMock(spec=Response)
not_found_response.headers = CaseInsensitiveDict(data={"content-type": "application/json"})
not_found_response.content = json.dumps({"error": "not found"})
not_found_response.status_code = 404