# AssertionError: assert datetime.datetime(2025, 1, 15, 10, 30) == datetime.datetime(2024, 6, 1, 0, 0)
  # expected freeze_time('2024-06-01') to apply

- **ID:** `python/pytest-freezegun-time-not-frozen`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The code under test imported datetime or time functions before freeze_time patched them, or uses a C-extension clock (e.g., time.monotonic_ns via numpy) that freezegun cannot intercept. Also common when the module does 'from datetime import datetime' and freezegun patches the class attribute incorrectly.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.5 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   from freezegun import freeze_time

@freeze_time('2024-06-01')
def test_expiry():
    # myapp/utils.py does: from datetime import datetime
    # freezegun patches datetime.datetime, so this works
    assert is_expired(datetime(2024, 5, 31))
   ```
2. **** (95% success)
   ```
   def is_expired(now=None):
    now = now or datetime.now(timezone.utc)
    return now > EXPIRY

def test_expiry():
    assert is_expired(now=datetime(2024, 5, 31, tzinfo=timezone.utc))
   ```

## Dead Ends

- **** — Nested freezes raise or silently override; the innermost wins, but the outer reference was already captured. (85% fail)
- **** — Sleep does not retroactively patch already-imported names; the test still sees real time. (90% fail)
