{
  "id": "python/pytest-parametrize-ids-duplicate",
  "signature": "ValueError: duplicate test IDs: 'test_case_0'",
  "signature_zh": "值错误：重复的测试ID：'test_case_0'",
  "regex": "ValueError:\\ duplicate\\ test\\ IDs:\\ 'test_case_0'",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "When using pytest.mark.parametrize with ids parameter, duplicate ID strings cause an error because test IDs must be unique within a parametrized test.",
  "root_cause_type": "generic",
  "root_cause_zh": "当使用pytest.mark.parametrize并设置ids参数时，重复的ID字符串会导致错误，因为参数化测试中的测试ID必须唯一。",
  "versions": [
    {
      "version": "7.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Removing the ids parameter entirely",
      "why_fails": "This loses descriptive test names, making test output harder to read.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a lambda function that returns a constant string",
      "why_fails": "This will still produce duplicate IDs if the lambda ignores input.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure all IDs in the ids list are unique",
      "success_rate": 0.95,
      "how": "@pytest.mark.parametrize('x', [1, 2, 3], ids=['case_1', 'case_2', 'case_3'])\ndef test_example(x):\n    ...\nEach ID must be different.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a function to generate unique IDs based on the parameter values",
      "success_rate": 0.9,
      "how": "def id_func(val):\n    return f'x={val}'\n@pytest.mark.parametrize('x', [1, 2, 3], ids=id_func)\ndef test_example(x):\n    ...\nThis ensures uniqueness.",
      "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-08-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}