{
  "id": "python/pytest-coverage-source-missing",
  "signature": "CoverageWarning: Module myapp was never imported. (module-not-imported)\nCoverageWarning: No data was collected. (no-data-collected)",
  "signature_zh": "CoverageWarning：模块 myapp 从未被导入。（module-not-imported）\nCoverageWarning：未收集到数据。（no-data-collected）",
  "regex": "CoverageWarning:\\ Module\\ myapp\\ was\\ never\\ imported\\.\\ \\(module\\-not\\-imported\\)\\\nCoverageWarning:\\ No\\ data\\ was\\ collected\\.\\ \\(no\\-data\\-collected\\)",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "pytest-cov was pointed at a source path that doesn't match the importable package name, or tests never import the package (e.g., only test submodules that import a different top-level name).",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest-cov 指向的源路径与可导入的包名不匹配，或者测试从未导入该包（例如仅测试导入了不同顶层名称的子模块）。",
  "versions": [
    {
      "version": "5.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "6.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": "Branch coverage doesn't fix missing source mapping.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Threshold doesn't affect data collection.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Extra deps don't fix path/name mismatch.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "pytest --cov=myapp --cov-report=term-missing tests/",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "# pyproject.toml\n[tool.coverage.run]\nsource = [\"myapp\"]\nbranch = true",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "# tests/conftest.py\nimport myapp  # noqa: F401 ensures coverage sees the package",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}