-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requests custom adapter is ignored #83
Comments
Hi, sorry - I don't think there's a way to support a custom adapter in requests-mock. Internally it's working at the same adapter level you are, so installing the mocker like that just means that we always return the mock adapter. As a stable interface this was really the easiest way to implement it. You could have a look at |
OK, I'll try |
So just for the sake of reference I will post this in every place I was looking for, in case someone else get here looking for this answer... I spent the last few days trying to achieve this with @httpretty.activate
def test_with_callback_response():
def request_callback(request, uri, response_headers):
return [500, response_headers, json.dumps({"hello": "world"})]
http_adapter = TimeoutHTTPAdapter()
session = requests.Session()
session.mount('http://', adapter=http_adapter)
session.mount('https://', adapter=http_adapter)
httpretty.register_uri(
httpretty.GET,
re.compile(r'http://.*'),
responses=[
httpretty.Response(
body='{"message": "HTTPretty :)"}',
status=403,
),
httpretty.Response(
body='{"message": "HTTPretty :)"}',
status=429,
),
httpretty.Response(
body='{"message": "HTTPretty :)"}',
status=500,
),
]
)
try:
response = session.get("http://example.co/status/")
except Exception as e:
print(len(httpretty.latest_requests())) The line under |
Hi, I use a custom adapter to implement a retry in a client class:
Then
session
is used to make requests like:Finally I test my client class but the retry doesn't work:
This issue may be related to #20.
The text was updated successfully, but these errors were encountered: