{
  "id": "python/pytest-cov-missing-coverage-data",
  "signature": "CoverageWarning: No data was collected. (no-data-collected)",
  "signature_zh": "覆盖率警告：未收集到任何数据。（无数据收集）",
  "regex": "CoverageWarning:\\ No\\ data\\ was\\ collected\\.\\ \\(no\\-data\\-collected\\)",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The pytest-cov plugin did not detect any code execution during tests, possibly because the test files are not importing the source modules, or the source code paths are misconfigured.",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest-cov插件在测试期间未检测到任何代码执行，可能是因为测试文件未导入源模块，或源代码路径配置错误。",
  "versions": [
    {
      "version": "4.1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "5.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reinstalling pytest-cov via pip",
      "why_fails": "The issue is not with the installation but with the test configuration or code structure.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding `--cov=myproject` without ensuring the source code is actually executed",
      "why_fails": "If the tests don't import the source modules, coverage still won't collect data.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure test files import the source modules that should be covered",
      "success_rate": 0.9,
      "how": "In your test file, add: from myproject import mymodule\nThen run: pytest --cov=myproject tests/",
      "condition": "",
      "sources": []
    },
    {
      "action": "Specify the source directory correctly in pytest.ini or pyproject.toml",
      "success_rate": 0.85,
      "how": "Add to pyproject.toml:\n[tool.pytest.ini_options]\naddopts = \"--cov=src\"\ncov_source = [\"src\"]\nThen run pytest.",
      "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": "true",
  "first_seen": "2024-02-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}