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


Python NonCallableMock.content方法代码示例

本文整理汇总了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
开发者ID:auvipy,项目名称:silk,代码行数:10,代码来源:test_config_meta.py

示例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
开发者ID:fako,项目名称:datascope,代码行数:32,代码来源:requests.py


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