{
  "id": "python/pytest-tmp-path-not-cleaned",
  "signature": "OSError: [Errno 28] No space left on device: '/tmp/pytest-of-runner/pytest-123/test_x0/data.bin'",
  "signature_zh": "OSError: [Errno 28] 设备上没有剩余空间: '/tmp/pytest-of-runner/pytest-123/test_x0/data.bin'",
  "regex": "OSError:\\ \\[Errno\\ 28\\]\\ No\\ space\\ left\\ on\\ device:\\ '/tmp/pytest\\-of\\-runner/pytest\\-123/test_x0/data\\.bin'",
  "domain": "python",
  "category": "system_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试向 tmp_path 写入大文件，加上 pytest 的 tmp_path 保留策略（默认保留 3 次运行）和并行 xdist worker，数据累积速度快于清理速度。",
  "versions": [
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Buying time, not fixing the leak; suites that grow will hit the same limit and the cost increases.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "RAM disk is smaller than /tmp; large test artifacts fill it faster and cause OOM or ENOSPC sooner.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "# pyproject.toml\n[tool.pytest.ini_options]\n# pytest keeps last 3 by default; use a fixture to clean large files\ndef test_big(tmp_path):\n    p = tmp_path / 'data.bin'\n    try:\n        p.write_bytes(b'x' * 10_000_000)\n        ...\n    finally:\n        p.unlink(missing_ok=True)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "# CI step\npytest --basetemp=/tmp/pytest-$CI_JOB_ID tests/\nrm -rf /tmp/pytest-$CI_JOB_ID\n\n# Or in conftest:\nimport shutil, pytest\n@pytest.fixture(scope='session', autouse=True)\ndef _clean_basetemp(request):\n    yield\n    shutil.rmtree(request.config.option.basetemp, ignore_errors=True)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2025-03-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}