{
  "id": "python/pytest-coverage-subprocess-not-measured",
  "signature": "Coverage.py warning: No data was collected. (no-data-collected)\nWARNING: Failed to generate report: No data to report.",
  "signature_zh": "Coverage.py 警告: 未收集到数据。(no-data-collected)\n警告: 生成报告失败: 无数据可报告。",
  "regex": "Coverage\\.py\\ warning:\\ No\\ data\\ was\\ collected\\.\\ \\(no\\-data\\-collected\\)\\\nWARNING:\\ Failed\\ to\\ generate\\ report:\\ No\\ data\\ to\\ report\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Tests spawn subprocesses (e.g., via subprocess.run or multiprocessing) and coverage is not propagated to them, so only the parent process is measured and often has no executed lines.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试生成子进程（例如通过 subprocess.run 或 multiprocessing），覆盖率未传播到子进程，因此仅测量父进程，而父进程通常没有执行任何行。",
  "versions": [
    {
      "version": "7.4.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "7.5.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the tests themselves only spawn subprocesses, the parent process executes no application code and coverage stays empty.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Only affects where data is written, not whether subprocesses are instrumented; the child still does not start coverage.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "# .coveragerc\n[run]\nconcurrency = multiprocessing\nparallel = true\n\n# conftest.py\nimport coverage\ncoverage.process_startup()\n\n# env\nCOVERAGE_PROCESS_START=.coveragerc",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "coverage run --concurrency=multiprocessing -m pytest tests/\ncoverage combine\ncoverage report --fail-under=85",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-01-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}