Hey guys, thanks for the course, nice job! Have learnt a thing or two so far.
Brought some feedback / issues I encountered in the Chapter 3.
Issue 1 - Getting the AsyncClient.__init__() got an unexpected keyword argument 'app' error when running pytest
Detailed error
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/tsar/python_venv/fastapi/lib/python3.10/site-packages/anyio/_backends/_asyncio.py:2234: in run_asyncgen_fixture
fixturevalue: T_Retval = self.get_loop().run_until_complete(
/usr/lib/python3.10/asyncio/base_events.py:649: in run_until_complete
return future.result()
/home/tsar/python_venv/fastapi/lib/python3.10/site-packages/anyio/_backends/_asyncio.py:2226: in _call_in_runner_task
return await future
/home/tsar/python_venv/fastapi/lib/python3.10/site-packages/anyio/_backends/_asyncio.py:2193: in _run_tests_and_fixtures
retval = await coro
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
client = <starlette.testclient.TestClient object at 0x7fb59e68b2e0>
@pytest.fixture()
async def async_client(client) -> AsyncGenerator:
> async with AsyncClient(app=app, base_url=client.base_url) as ac:
E TypeError: AsyncClient.__init__() got an unexpected keyword argument 'app'
mediaapi/tests/conftest.py:33: TypeError
================================================================================ short test summary info ================================================================================
ERROR mediaapi/tests/routers/test_post.py::test_create_post - TypeError: AsyncClient.__init__() got an unexpected keyword argument 'app'
Downgrading httpx version to httpx==0.27.2 in requirements-dev.txt resolved the issue for me.
Issue 2 - http 200 vs http 201
For me the post requests made from async def test_create_comment (it' in the tests/routers/test_post.py) return http 200, not 201. Haven't tried to pinpoint the cause (could also be a difference between the fastapi or some other package's versions), just switched from
assert response.status_code == 201
to
assert response.status_code in [200, 201]
in tests/routers/test_post.py
Can't make a PR since all the course source code is zipped, so just reporting here.
Thanks again!
BR
Hey guys, thanks for the course, nice job! Have learnt a thing or two so far.
Brought some feedback / issues I encountered in the
Chapter 3.Issue 1 - Getting the
AsyncClient.__init__() got an unexpected keyword argument 'app'error when runningpytestDetailed error
Downgrading
httpxversion tohttpx==0.27.2inrequirements-dev.txtresolved the issue for me.Issue 2 - http 200 vs http 201
For me the post requests made from
async def test_create_comment(it' in thetests/routers/test_post.py) returnhttp 200, not201. Haven't tried to pinpoint the cause (could also be a difference between thefastapior some other package's versions), just switched fromto
in
tests/routers/test_post.pyCan't make a PR since all the course source code is zipped, so just reporting here.
Thanks again!
BR