Automatically activate responses across your py.test-powered test suite (thus preventing HTTP requests).
$ pip install pytest-responsesIf particular tests need access to external domains, you can use the withoutresponses marker:
@pytest.mark.withoutresponsesdeftest_disabled():
withpytest.raises(ConnectionError):
requests.get('http://responses.invalid')
assertlen(responses.calls) ==0Additionally, you can use the responses fixture:
deftest_enabled(responses):
withpytest.raises(ConnectionError):
requests.get('http://responses.invalid')
assertlen(responses.calls) ==1