Open alext opened 3 years ago
Bump +1
One workaround is to convert to ISO string before passing to freeze_time
.
If it helps anybody, we wrote a simple wrapper a while ago. Will also throw it out there to the maintainers of this repo that happy to submit a similar, simple fix, if amenable:
def freeze_time(when: str | date | datetime):
"""Drop-in replacement that fixes library error working with Pendulum datetime instances.
https://github.com/spulec/freezegun/issues/411
"""
return freezegun.freeze_time(when if isinstance(when, str) else when.isoformat())
I'm seeing the following error when using the stdlib datetime.now while time is frozen to a pendulum datetime object:
freezegun: 1.1.0 pendulum: 2.1.2
Use-case for mixing the 2 datetime libraries is that my app code uses pendulum, but uses a library that uses the stdlib datetime libraries.