{
  "id": "python/importerror-no-module-named-tests",
  "signature": "ImportError: No module named tests",
  "signature_zh": "导入错误：没有名为 tests 的模块",
  "regex": "ImportError:\\ No\\ module\\ named\\ tests",
  "domain": "python",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "The test module or package is missing from the Python path, often due to incorrect directory structure or missing __init__.py.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试模块或包不在 Python 路径中，通常由于目录结构不正确或缺少 __init__.py。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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 sys.path.append manually",
      "why_fails": "Works temporarily but not portable; can cause path conflicts.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Installing tests as a package via pip",
      "why_fails": "Tests are not meant to be installed; they are run from source.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure __init__.py exists in test directory",
      "success_rate": 0.9,
      "how": "touch tests/__init__.py",
      "condition": "",
      "sources": []
    },
    {
      "action": "Run pytest with PYTHONPATH set",
      "success_rate": 0.85,
      "how": "PYTHONPATH=. 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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}