跳至主要内容

py.test集成响应

项目描述

https://img.shields.io/pypi/v/pytest-responses.svg https://github.com/getsentry/pytest-responses/workflows/Test/badge.svg

自动激活py.test测试套件中的响应(从而防止HTTP请求)。

$ pip install pytest-responses

如果特定测试需要访问外部域名,您可以使用withoutresponses标记

@pytest.mark.withoutresponses
def test_disabled():
    with pytest.raises(ConnectionError):
        requests.get('http://responses.invalid')

    assert len(responses.calls) == 0

此外,您还可以使用responses测试夹具

def test_enabled(responses):
    with pytest.raises(ConnectionError):
        requests.get('http://responses.invalid')

    assert len(responses.calls) == 1

项目详情


下载文件

为您的平台下载文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

此版本没有提供源代码分发文件。请参阅生成分发存档的教程。

构建分发

pytest_responses-0.5.1-py2.py3-none-any.whl (6.7 kB 查看哈希值)

上传时间: Python 2 Python 3

支持者