-
Notifications
You must be signed in to change notification settings - Fork 135
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
RuntimeError: Runner is closed in pytest #619
Comments
Notes: The third test seems irrelevant. The second test also passes if the |
Minimal test case with module scoped fixtures: import pytest
pytestmark = pytest.mark.anyio
@pytest.fixture(scope="session")
def anyio_backend():
return "asyncio"
@pytest.fixture(scope="module")
async def bbbbbb():
yield ""
@pytest.fixture(scope="module")
async def aaaaaa():
yield ""
async def test_1(bbbbbb):
pass
async def test_2(aaaaaa, bbbbbb):
pass |
I just ran into this problem at my day job 😅 |
The issue is that the first fixture gets "ownership" of the test runner, and if that fixture isn't the last one to be torn down, the rest will fail with this error at teardown. |
@EdorianDark Let me know if you're available to review the fix PR or not. |
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
AnyIO version
4.0.0
Python version
3.11.5
What happened?
The error message "RuntimeError: Runner is closed" appears.
How can we reproduce the bug?
The following leads to the described error:
I get always the error in the skipped test
Not that if I change it to
pytestmark = pytest.mark.asyncio
there is no error.Also the error goes away if I change the order of the function parameters to have bbbbb always in front.
The text was updated successfully, but these errors were encountered: