-
Notifications
You must be signed in to change notification settings - Fork 86
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
Send a mocked request more than once then got ClientConnectionError #164
Comments
i have found that if i m.get('http://example.com', callback=callback)
m.get('http://example.com', callback=callback)
m.get('http://example.com', callback=callback)
for i in range(2):
resp = await session.get('http://example.com')
assert resp.status == 418 then resolved the problem |
@leftvalue I was having this issue too. I'm currently switching a project over from the synchronous @pytest.mark.asyncio
async def test_callback(aiohttp_client):
with aioresponses() as m:
session = aiohttp.ClientSession()
m.get('http://example.com', callback=callback, repeat=True)
for i in range(2): # 1 is ok,2 cannot pass
resp = await session.get('http://example.com')
assert resp.status == 418 where you add the kwarg |
@leftvalue Hi, |
@pnuckowski may I ask, why is this the default behavior? Wouldn't a user want the mock to hold in place until the end of the test, or until they were to explicitly state a passthrough to make a real request? IMO this current default behavior could lead to tests making unintended requests to real infrastructure. I'd be happy to take a shot at it and make a PR if you agree. Otherwise it would be of great help to specify the |
@internetofjames In all of my projects I rarely wanted a mock that holds all/specific request and don"t feel it should be changed. To hit real infrastructure developer has to define which url should be passed (passthrough argument), so there is no option to hit infrastructure by mistake using default configuration. According to documentation, indeed there was few PR with improvements and new features and doc are lack of mentioning of them. This is the task at the top of my list to improve :) I'm wondering how to structure documentation, so If you read (lately) really good written docs, please let me know :) it might help me to make it right:) |
@pnuckowski some docs that came to mind were for the |
Adding docs would help people find this "hidden" argument :) |
@pnuckowski I've made a pull request adding the missing |
when i send a mocked request more than once, got
../../venv/lib/python3.7/site-packages/aioresponses/core.py:392: ClientConnectionError
the error is
wonder if anyone has see the problem before, or perhaps my usage is somewhere bad?
The text was updated successfully, but these errors were encountered: