{
  "id": "python/pytest-collection-error",
  "signature": "CollectionError: cannot collect 'test_foo' because it is not a function or class",
  "signature_zh": "收集错误：无法收集 'test_foo'，因为它不是函数或类",
  "regex": "CollectionError:\\ cannot\\ collect\\ 'test_foo'\\ because\\ it\\ is\\ not\\ a\\ function\\ or\\ class",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "pytest 试图收集一个名为 test_foo 的变量或对象，而不是测试函数",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest 试图收集一个名为 test_foo 的变量或对象，而不是测试函数",
  "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.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "只适用于类，不适用于变量",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "my_foo = 123",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "collect_ignore = ['test_foo']",
      "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-04-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}