{
  "id": "python/pytest-coverage-no-data-collected",
  "signature": "CoverageWarning: No data was collected. (no-data-collected)\nWARNING: Failed to find data for module 'myapp'",
  "signature_zh": "CoverageWarning: 未收集到数据。(no-data-collected)\nWARNING: 未能找到模块 'myapp' 的数据",
  "regex": "CoverageWarning:\\ No\\ data\\ was\\ collected\\.\\ \\(no\\-data\\-collected\\)\\\nWARNING:\\ Failed\\ to\\ find\\ data\\ for\\ module\\ 'myapp'",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "coverage run was pointed at the wrong source, or pytest is executed under a different interpreter/subprocess than the one coverage instruments. Common when using pytest-xdist without --cov or when tests spawn subprocesses that coverage does not trace.",
  "root_cause_type": "generic",
  "root_cause_zh": "coverage run 指向了错误的源码，或者 pytest 在与 coverage 插桩不同的解释器/子进程中执行。常见于使用 pytest-xdist 但未加 --cov，或测试启动的子进程未被 coverage 追踪。",
  "versions": [
    {
      "version": "5.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Broadens the source but if coverage is not started under the same process, still collects nothing.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Correct in principle, but if pytest-xdist is active the workers are separate processes and the main process records no data.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.94,
      "how": "pip install pytest-cov\npytest --cov=myapp --cov-report=term-missing -n auto",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "# .coveragerc\n[run]\nconcurrency = multiprocessing\nparallel = True\nsource = myapp",
      "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": "2024-08-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}