time-machine
time-machine copied to clipboard
Raise our own `utcnow` `DeprecationWarning` with the right `stacklevel`
Previously, when time is mocked, no DeprecationWarning would be reported at all, and when time is not mocked, the original datetime.utcnow would misattribute its reported DeprecationWarning to the code of time_machine itself. Fix both cases to attribute the DeprecationWarning to the user code that called utcnow, by raising it ourselves with the right stacklevel, and test that we did so correctly.
- Fixes #445.