You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello and thanks for the work on this awesome library!
It seems freezegun.freeze_time doesn't work well when pytest is ran with --import-mode=importlib.
I've noticed importing the datetime class from the datetime module now bypasses freezing (in test code, not in app code):
# this won't be frozen when using importlib mode
from datetime import datetime
datetime.utcnow()
# this still works as expected
import datetime
datetime.datetime.utcnow()
This seems to only impact datetime usage in tests. Application code importing the datetime class from the datetime module still works as expected.
Updated the description to clarify this only affects the usage of the datetime class via "from" import in test code. Usage in application code seems to still work as expected.
I think I have the same issue. I did not use "--import-mode=importlib", but the source code itself uses importlib. The importing of a module using importlib fails when I add the freeze_time decorator to the test which executes that part of the code.
Hello and thanks for the work on this awesome library!
It seems
freezegun.freeze_time
doesn't work well when pytest is ran with--import-mode=importlib
.I've noticed importing the datetime class from the datetime module now bypasses freezing (in test code, not in app code):
This seems to only impact datetime usage in tests. Application code importing the datetime class from the datetime module still works as expected.
According to the changelog for 6-0-0 the intention is for this mode to become the default in the future, and feedback is being collected on pytest-dev/pytest#7245.
The text was updated successfully, but these errors were encountered: