freezegun
freezegun copied to clipboard
move_to not supported when ticks enabled
it seems like only StepTickTimeFactory
and FrozenDateTimeFactory
have this method enabled but not TickingDateTimeFactory
Thanks for opening! I am marking this as an enhancement.
is it really an enhancement? The docs say this should work. Btw here's my hack around it:
class WraptTickingDateTimeFactory(wrapt.ObjectProxy):
# https://github.com/spulec/freezegun/issues/350
def move_to(self, target_datetime):
"""Moves frozen date to the given ``target_datetime``"""
self.__wrapped__.time_to_freeze = freezegun.api._parse_time_to_freeze(target_datetime)
self.__wrapped__.start = freezegun.api.real_datetime.now()
if isinstance(frozen_datetime, freezegun.api.TickingDateTimeFactory):
frozen_datetime = WraptTickingDateTimeFactory(frozen_datetime)
What's the status of this? It's really frustrating, especially when used together with pytest-freezegun
library, which does not allow to change the original factory of the freezer
fixture on the fly.
The status is there is no PR to fix it.
We need a PR! :)
https://github.com/spulec/freezegun/pull/531
I'm not sure where to add tests for this. Also, is the reset of start
really required?
Created a PR for this - https://github.com/spulec/freezegun/pull/533
For the time being, to circumvent the issue, you could (if possible) simply add the argument auto_tick_seconds=1
to your freeze_time
call.