{
  "id": "python/pytest-freeze-time-inconsistent",
  "signature": "AssertionError: assert datetime.datetime(2025, 1, 1, 0, 0) == datetime.datetime(2024, 6, 1, 12, 0)",
  "signature_zh": "AssertionError: assert datetime.datetime(2025, 1, 1, 0, 0) == datetime.datetime(2024, 6, 1, 12, 0)（冻结时间不一致）",
  "regex": "AssertionError:\\ assert\\ datetime\\.datetime\\(2025,\\ 1,\\ 1,\\ 0,\\ 0\\)\\ ==\\ datetime\\.datetime\\(2024,\\ 6,\\ 1,\\ 12,\\ 0\\)",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "freezegun's freeze_time doesn't patch datetime in C extensions, or the code uses time.monotonic / time.time_ns which freezegun doesn't override by default.",
  "root_cause_type": "generic",
  "root_cause_zh": "freezegun 的 freeze_time 未修补 C 扩展中的 datetime，或代码使用 time.monotonic / time.time_ns，而 freezegun 默认不覆盖这些。",
  "versions": [
    {
      "version": "1.4.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.5.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "tick advances time by real elapsed seconds but doesn't patch C-level time functions; the mismatch persists.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Module-level freeze doesn't reach C extensions or subprocesses; portions still read the real clock.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "import time\nfrom freezegun import freeze_time\n\ndef test_x(monkeypatch):\n    with freeze_time('2025-01-01'):\n        monkeypatch.setattr(time, 'monotonic', lambda: 0.0)\n        assert run() == expected",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "class Clock:\n    def now(self): return datetime.now(timezone.utc)\n\ndef test_x():\n    c = Clock()\n    with freeze_time('2025-01-01'):\n        assert c.now().year == 2025",
      "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": "partial",
  "first_seen": "2025-01-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}