{
  "id": "python/pytest-assertion-rewrite-failure",
  "signature": "AssertionError: assert 200 == 404\n +  where 200 = <Response [200]>.status_code",
  "signature_zh": "AssertionError: assert 200 == 404\n +  其中 200 = <Response [200]>.status_code",
  "regex": "AssertionError:\\ assert\\ 200\\ ==\\ 404\\\n\\ \\+\\ \\ where\\ 200\\ =\\ <Response\\ \\[200\\]>\\.status_code",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The test expected a 404 status code but received 200. This indicates the API endpoint returned a successful response instead of the expected error. Common causes include incorrect URL, missing authentication, or the resource actually existing when the test assumes it doesn't.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试期望返回404状态码但收到了200。这表明API端点返回了成功响应而不是预期的错误。常见原因包括URL错误、缺少身份验证，或者资源实际存在而测试假设它不存在。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This masks the real issue and makes the test useless for detecting regressions; the test will always pass regardless of actual behavior.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If the resource is immediately available, sleeping won't change the status code from 200 to 404; it just slows down tests.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This bypasses the real integration and may hide bugs in the actual endpoint; the test no longer validates real behavior.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Print the full URL and check if the resource exists:\n\nprint(response.url)\n# Manually query the database or use curl to confirm the resource is missing before the test.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Use fixtures to guarantee the resource does not exist:\n\n@pytest.fixture\ndef cleanup_user():\n    User.objects.filter(id=123).delete()\n    yield\n    User.objects.filter(id=123).delete()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "If the endpoint returns 200 for authorized users, adjust the test to use an unauthorized client or a different user without access.",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}