# OSError: [Errno 28] No space left on device: '/tmp/pytest-of-runner/pytest-123/test_x0/data.bin'

- **ID:** `python/pytest-tmp-path-not-cleaned`
- **Domain:** python
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Tests write large files into tmp_path, and pytest's tmp_path retention (default 3 runs) plus parallel xdist workers accumulate data faster than it is pruned.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   # pyproject.toml
[tool.pytest.ini_options]
# pytest keeps last 3 by default; use a fixture to clean large files
def test_big(tmp_path):
    p = tmp_path / 'data.bin'
    try:
        p.write_bytes(b'x' * 10_000_000)
        ...
    finally:
        p.unlink(missing_ok=True)
   ```
2. **** (88% success)
   ```
   # CI step
pytest --basetemp=/tmp/pytest-$CI_JOB_ID tests/
rm -rf /tmp/pytest-$CI_JOB_ID

# Or in conftest:
import shutil, pytest
@pytest.fixture(scope='session', autouse=True)
def _clean_basetemp(request):
    yield
    shutil.rmtree(request.config.option.basetemp, ignore_errors=True)
   ```

## Dead Ends

- **** — Buying time, not fixing the leak; suites that grow will hit the same limit and the cost increases. (80% fail)
- **** — RAM disk is smaller than /tmp; large test artifacts fill it faster and cause OOM or ENOSPC sooner. (85% fail)
