# RuntimeError: no running event loop

- **ID:** `python/pytest-asyncio-no-running-event-loop`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

An async test or fixture is executed without an active asyncio event loop. Typically pytest-asyncio mode is not configured, the test lacks @pytest.mark.asyncio, or the fixture is sync but awaits.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 0.21.x | active | — | — |
| 0.23.x | active | — | — |

## Workarounds

1. **** (93% success)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
asyncio_mode = "auto"

# or pytest.ini
# [pytest]
# asyncio_mode = auto
   ```
2. **** (90% success)
   ```
   import pytest, pytest_asyncio

@pytest_asyncio.fixture
async def client():
    async with AsyncClient() as c:
        yield c

@pytest.mark.asyncio
async def test_ping(client):
    r = await client.get('/ping')
    assert r.status_code == 200
   ```

## Dead Ends

- **** — pytest-asyncio already manages the loop; nested asyncio.run raises 'asyncio.run() cannot be called from a running event loop' or double-closes the loop. (70% fail)
- **** — Sync fixtures cannot yield awaited values; the coroutine object is returned instead of the resolved value, causing the exact error downstream. (65% fail)
