-
Notifications
You must be signed in to change notification settings - Fork 38
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
respx decorator breaks pytest fixture #210
Comments
This does seem like a bug, the ...
resp_mock = respx.mock(assert_all_called=True)
def test_respx(httpx_client: AsyncClient):
... I tried to solve this but unfortunately it has taken me too long to figure it out 😅 |
Thanks @gregbrowndev and @KallieLev for pointing this out! With the Without the decorator, the Currently it seems to be like you're describing, i.e. a I'd recommend, at least for now, to instead use the respx fixture and the respx marker for tests that need other pytest fixtures, rather than the respx-decorator. @pytest.fixture
async def httpx_client():
async with httpx.AsyncClient() as client:
yield client
@pytest.mark.respx(assert_all_called=True) # NOTE: optional marker for configuration
def test_respx(
respx_mock: MockRouter,
httpx_client: AsyncClient,
):
... |
@gregbrowndev, I managed to fix a PR that solves the bug 😉. ... though, since you're using pytest, my suggested @KallieLev, thanks for #211 ... it'll be a duplicate once #213 is merged and get closed. |
Hi,
Uncommenting the decorator on the test below throws an error:
I'm doing a few things that might seem odd:
httpx_client
as a fixture - not odd, but I haven't seen this done in any of the docs. Note, creatingAsyncClient
in the test works fine.AsyncClient
onasyncio.get_event_loop()
instead of making the pytest async. This test is trying to prove some behaviour while we migrate to async HTTPX. Our application is synchronous but we want to make some concurrent requests within a deeply buried module.Nonetheless, this seems like a bug in respx.
Thanks
The text was updated successfully, but these errors were encountered: