{
  "id": "python/pytest-collection-module-error",
  "signature": "ImportError: cannot import name 'test_helper' from 'tests' (unknown location)",
  "signature_zh": "导入错误：无法从 'tests' 导入名称 'test_helper'（位置未知）",
  "regex": "ImportError:\\ cannot\\ import\\ name\\ 'test_helper'\\ from\\ 'tests'\\ \\(unknown\\ location\\)",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "pytest 在收集测试时无法正确导入测试模块，通常由于缺少 __init__.py 或路径配置错误。",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest 在收集测试时无法正确导入测试模块，通常由于缺少 __init__.py 或路径配置错误。",
  "versions": [
    {
      "version": "7.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "可能掩盖包结构问题，且 pytest 的导入机制不同。",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "如果使用 pytest 的 rootdir 机制，可能需要保留。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "在 tests 目录下创建 __init__.py，并确保模块路径正确。",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "在 pyproject.toml 或 pytest.ini 中设置 `pythonpath = .` 确保项目根目录在路径中。",
      "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-09-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}