# AssertionError: assert datetime.datetime(2024, 1, 1, 0, 0) == datetime.datetime(2025, 6, 1, 12, 0)
# freezegun is active but the imported datetime is the real one

- **ID:** `python/pytest-freezegun-datetime-import`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The code under test imported datetime as 'from datetime import datetime' before freezegun patched the module, so the test holds a reference to the unpatched class.

## Version Compatibility

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

## Workarounds

1. **** (94% success)
   ```
   # BAD:  from datetime import datetime
# GOOD: import datetime
then use datetime.datetime.now()

# Test:
from freezegun import freeze_time

@freeze_time('2025-06-01 12:00:00')
def test_x():
    assert get_now() == datetime.datetime(2025, 6, 1, 12, 0)
   ```
2. **** (80% success)
   ```
   import importlib

@freeze_time('2025-06-01')
def test_x():
    import myapp.clock
    importlib.reload(myapp.clock)
    assert myapp.clock.now().year == 2025
   ```

## Dead Ends

- **** — tick only affects the patched clock; the unpatched datetime reference is unaffected and still returns real time. (85% fail)
- **** — Timezone is not the issue; the datetime class itself is not the one freezegun patched. (92% fail)
