import anyio
import pytest
@pytest.fixture
async def scope():
    with anyio.CancelScope() as scope:
        yield scope
async def test(scope: anyio.CancelScope):
    passThis will raise a RuntimeError: Attempted to exit cancel scope in a different task than it was entered in.
After looking at the code for fixture cleanup, I don't see an easy way to work around this, but it's quite a severe issue as it hinders working with cancel scopes / code that uses cancel scopes.