-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
TypeError: _on_request() takes exactly 3 arguments (8 given) #138
Comments
@MathMagique if issue is not reproducible on latest master, please consider closing this issue |
@markstory it is unclear how to reproduce. While we have an example of custom adapter running: responses/responses/test_responses.py Line 783 in 5084e3f
|
Let me know if its better to open a new issue. I am running into this with the 0.1.3.0 release of CacheControl it seems to only occur if you explicitly pass the arguments that Here is an adapted test based on the existing custom adapter test. It demonstrates the difference between the two calling patterns. import requests
import responses
from responses.tests.test_responses import assert_response
def test_passing_custom_adapter():
@responses.activate
def run():
url = "http://example.com"
responses.add(responses.GET, url, body=b"test")
calls = [0]
class DummyAdapter(requests.adapters.HTTPAdapter):
def send(self, *a, **k):
calls[0] += 1
return super().send(*a, **k)
# Test that the adapter is actually used
session = requests.Session()
session.mount("http://", DummyAdapter())
session.get(url, allow_redirects=False)
assert calls[0] == 1
# Test that the response is still correctly emulated
session = requests.Session()
session.mount("http://", DummyAdapter())
resp = session.get(url)
assert_response(resp, "test")
run()
def test_breaking_custom_adapter():
@responses.activate
def run():
url = "http://example.com"
responses.add(responses.GET, url, body=b"test")
calls = [0]
class DummyAdapter(requests.adapters.HTTPAdapter):
def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
calls[0] += 1
return super().send(request, stream, timeout, verify, cert, proxies)
# Test that the adapter is actually used
session = requests.Session()
session.mount("http://", DummyAdapter())
session.get(url, allow_redirects=False)
assert calls[0] == 1
# Test that the response is still correctly emulated
session = requests.Session()
session.mount("http://", DummyAdapter())
resp = session.get(url)
assert_response(resp, "test")
run() The environment is
|
@hakjoon and add traceback and all relevant info |
I use
responses
while testing a few calls to a REST API. Calls to the REST API are made usingrequests.HTTPAdapter.send()
(https://github.com/kennethreitz/requests/blob/master/requests/adapters.py#L375)Mocking these requests with
responses
fails (at least when I have not prepared responses) with the following error message:unbound_on_send
is located inresponses
. The values for parametera
are the (default) parameters passed toHTTPAdapter.send()
.These are the relevant lines in
responses
:The text was updated successfully, but these errors were encountered: