-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecation warnings are silenced while time is mocked #445
Comments
There's a further bug here which I originally (incorrectly) reported as python/typeshed#11849. This code runs fine: class MyDT(datetime):
pass
my_dt = MyDT.now()
assert type(my_dt) == MyDT This code asserts: class MyDT(datetime):
pass
with time_machine.travel(0):
my_dt = MyDT.now()
assert type(my_dt) == MyDT |
Ah yes, that deprecation. I am not sure what can be immediately done off the top of my head, since we deliberately avoid calling the underlying method during time travelling. Please make a second issue for the typing difference. |
Done. #446. |
andersk
added a commit
to andersk/time-machine
that referenced
this issue
Oct 23, 2024
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 adamchainz#445. Signed-off-by: Anders Kaseorg <[email protected]>
andersk
added a commit
to andersk/time-machine
that referenced
this issue
Oct 23, 2024
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 adamchainz#445. Signed-off-by: Anders Kaseorg <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python Version
3.12.2
pytest Version
8.1.1
Package Version
2.14.1
Description
The text was updated successfully, but these errors were encountered: