time-machine icon indicating copy to clipboard operation
time-machine copied to clipboard

Raise our own `utcnow` `DeprecationWarning` with the right `stacklevel`

Open andersk opened this issue 1 year ago • 3 comments

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.

andersk avatar Oct 23 '24 02:10 andersk