# TimeoutError: Test timed out after 30 seconds

- **ID:** `python/pytest-timeout-test-hang`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A test takes longer than the specified timeout, often due to infinite loops, slow I/O, or blocking calls.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## Workarounds

1. **Add debugging output to identify where the test hangs.** (85% success)
   ```
   Insert print statements or use logging to trace execution.
   ```
2. **Use pytest-timeout plugin to set a timeout and catch hanging tests.** (90% success)
   ```
   pytest --timeout=60 test_file.py
   ```

## Dead Ends

- **Increasing the timeout value without investigating the cause** — The underlying issue (e.g., infinite loop) will cause the test to hang indefinitely. (70% fail)
- **Removing the timeout decorator to avoid failure** — The test may still hang indefinitely, blocking the test suite. (80% fail)
