# RuntimeError: no running event loop
async def functions are not natively supported. You need to install a suitable plugin for your async framework, for example: - anyio - pytest-asyncio

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

## Root Cause

pytest does not run async test functions without a plugin; without pytest-asyncio (or anyio) configured, coroutine tests are skipped or raise this error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   pip install pytest-asyncio

# pytest.ini
[pytest]
asyncio_mode = auto

# tests
import pytest

@pytest.mark.asyncio
async def test_fetch():
    assert await fetch()
   ```
2. **** (90% success)
   ```
   pip install anyio

# pytest.ini
[pytest]
addopts = --anyio-mode=auto

# tests
import pytest

@pytest.mark.anyio
async def test_fetch():
    assert await fetch()
   ```

## Dead Ends

- **** — Works for trivial tests but breaks fixtures, event-loop-scoped resources, and any test that relies on pytest's async fixtures. (60% fail)
- **** — The marker is unknown to pytest and triggers a PytestUnknownMarkWarning; the coroutine is still not awaited. (90% fail)
- **** — The ini option is only recognized by pytest-asyncio; without the plugin it has no effect. (95% fail)
