{
  "id": "python/pytest-cov-coverage-error",
  "signature": "CoverageError: No data collected for module 'my_module'",
  "signature_zh": "覆盖率错误：未收集到模块 'my_module' 的数据",
  "regex": "CoverageError:\\ No\\ data\\ collected\\ for\\ module\\ 'my_module'",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The coverage plugin (pytest-cov) is not properly configured to measure the target module, often due to missing --cov option or incorrect module path.",
  "root_cause_type": "generic",
  "root_cause_zh": "覆盖率插件 (pytest-cov) 未正确配置以测量目标模块，通常是由于缺少 --cov 选项或模块路径不正确。",
  "versions": [
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding --cov-report=html without specifying --cov",
      "why_fails": "Coverage data collection requires --cov to specify the module; without it, no data is collected.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting coverage in setup.cfg but not using --cov on command line",
      "why_fails": "Command-line options override config file; if --cov is missing, coverage may not run.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Specify the module to measure using --cov flag.",
      "success_rate": 0.95,
      "how": "pytest --cov=my_module",
      "condition": "",
      "sources": []
    },
    {
      "action": "Configure coverage in pyproject.toml under [tool.coverage.run] section.",
      "success_rate": 0.9,
      "how": "[tool.coverage.run]\nsource = ['my_module']",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}