Closed mhassan5809 closed 2 months ago
@mhassan5809 The example you provided is neither self-contained, nor minimal. That means I cannot run and debug it.
Looking at the code, it could be related to the scopes of the async fixtures. I see you're using pytest-asyncio v0.24. Are you aware of the newly introduced async_default_fixture_loop_scope config option? If so, what value did you set it to?
Thanks for the reply @seifertm. async_default_fixture_loop_scope value is session.
I will create a minimal app and paste it here tomorrow so that you can run it. Thanks.
@MahmudulHassan5809 Thanks for the quick turnaround.
If _async_default_fixture_loopscope is set to session, that means the fixtures run in a different asyncio event loop than TestExample.test_example
. Changing the @pytest.mark.asyncio
decorator to @pytest.mark.asyncio(loop_scope="session")
should resolve the issue. Alternatively, you can run all tests in the session loop
@seifertm thanks a lot. seems the problem is solved . I appreciate your guidance. Thank You very much.
main class
conftest.py
test_api.py
Errors
if remove await db.drop_database() then it works fine .
could not solve the problem . any idea why i got this error or how to solve it . Help Please. Thanks pytest-asyncio = "^0.24.0"