avallbona / pytest-responses

py.test integration for responses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pytest-responses

Automatically activate responses across your py.test-powered test suite (thus preventing HTTP requests).

shell

$ pip install pytest-responses

If particular tests need access to external domains, you can use the withoutresponses marker:

python

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

assert len(responses.calls) == 0

Additionally, you can use the responses fixture:

python

def test_enabled(responses):
with pytest.raises(ConnectionError):

requests.get('http://responses.invalid')

assert len(responses.calls) == 1

About

py.test integration for responses

License:Apache License 2.0


Languages

Language:Python 92.3%Language:Makefile 7.7%