-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
I would like to test Connection/Timeout Exception for requests calls.
``
from unittest import mock
@mock.patch('requests.post', side_effect=requests.exceptions.ConnectTimeout)
def test_connection_error():
``
As stated in docs here
The fixture then provides the same interface as the requests_mock.Mocker letting you use requests-mock as you would expect.
requests-mock pytest plugin helps testing other failure scenarios, but not raising exception as side-effect. Hence I would like to define custom Adapter for requests-mock as documented here
This is not possible with requests-mock pytest plugin and without importing requests-mock module
However this would create namespace class hence, we need something like this
import requests_mock as req_mock_mod
Is there any possibility of using plugin to raise Request.Exception and/or define custom adapters ?