# AssertionError: assert '2026-03-01' == '2024-01-01'
  # datetime.now() not frozen inside test

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

## Root Cause

freezegun's freeze_time decorator patches datetime at import time, but the code under test imported datetime as 'from datetime import datetime', binding the original class before the patch. The patched module-level datetime is not used.

## Version Compatibility

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

## Workarounds

1. **** (92% success)
   ```
   import datetime

def get_date():
    return datetime.datetime.now().date()
   ```
2. **** (88% success)
   ```
   import time_machine
from datetime import datetime

@time_machine.travel('2024-01-01')
def test_date():
    assert datetime.now().date().isoformat() == '2024-01-01'
   ```

## Dead Ends

- **** — Time is not the issue; the reference is bound to the unpatched class regardless of duration. (80% fail)
- **** — time-machine also patches the datetime module; the pre-bound reference still points to the original. (70% fail)
