-
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
mocking ignores base_url #230
Comments
A small test that illustrates it (in case is useful) import pytest
from aiohttp import ClientSession
from aioresponses import aioresponses
@pytest.fixture
def mock_aioresponse():
with aioresponses() as m:
m.get("http://example.com/foo", status=200)
yield m
async def test_with_full_url(mock_aioresponse: aioresponses):
async with ClientSession() as session:
async with session.get("http://example.com/foo") as response:
assert response.ok
async def test_with_relative_url(mock_aioresponse: aioresponses):
async with ClientSession(base_url="http://example.com") as session:
async with session.get("/foo") as response:
assert response.ok test_aioreponses.py::test_with_full_url PASSED
test_aioreponses.py::test_with_relative_url FAILED |
A dirty hack solves the problem.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
aiohttp.ClientSession
takes abase_url
(https://docs.aiohttp.org/en/stable/client_reference.html?highlight=base_url#aiohttp.ClientSession) that is then used to build the URL with.request()
and other methods.Sample usage:
Unfortunately,
aioresponses
ignores that, so it's not possible to mock the full URL, because aioresponses would only pass/get
to its matchers.The text was updated successfully, but these errors were encountered: