{
  "id": "python/nameerror-name-not-defined",
  "signature": "NameError: name 'setup_method' is not defined",
  "signature_zh": "名称错误：名称 'setup_method' 未定义",
  "regex": "NameError:\\ name\\ 'setup_method'\\ is\\ not\\ defined",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A test class uses a method like setup_method without defining it, or it is misspelled.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试类使用了如 setup_method 的方法但未定义，或拼写错误。",
  "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": "Defining setup_method inside test function",
      "why_fails": "setup_method should be a method of the test class, not nested inside a test.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using setup_method as a fixture",
      "why_fails": "setup_method is a unittest convention; pytest uses fixtures instead.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Define setup_method as class method",
      "success_rate": 0.95,
      "how": "class TestClass:\n    def setup_method(self):\n        pass",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use pytest fixture instead",
      "success_rate": 0.9,
      "how": "@pytest.fixture(autouse=True)\ndef setup_method(self):\n    pass",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-01-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}