py.test integration for responses
Switch branches/tags
Nothing to show
Clone or download
dcramer Merge pull request #4 from keimlink/add-marker
Add withoutresponses marker
Latest commit c038ca6 Oct 10, 2017

README.rst

pytest-responses

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

$ pip install pytest-responses

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

@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:

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

    assert len(responses.calls) == 1