Skip to content
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

move_to not supported when ticks enabled #350

Closed
thehesiod opened this issue May 22, 2020 · 7 comments · Fixed by #533
Closed

move_to not supported when ticks enabled #350

thehesiod opened this issue May 22, 2020 · 7 comments · Fixed by #533
Labels

Comments

@thehesiod
Copy link

it seems like only StepTickTimeFactory and FrozenDateTimeFactory have this method enabled but not TickingDateTimeFactory

@spulec
Copy link
Owner

spulec commented May 23, 2020

Thanks for opening! I am marking this as an enhancement.

@thehesiod
Copy link
Author

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)

@spulec spulec added bug and removed enhancement labels Jul 26, 2020
@lokhman
Copy link

lokhman commented Aug 31, 2022

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.

@boxed
Copy link
Contributor

boxed commented Sep 1, 2022

The status is there is no PR to fix it.

@lokhman
Copy link

lokhman commented Sep 1, 2022

We need a PR! :)

@ashishnitinpatil
Copy link
Contributor

ashishnitinpatil commented Feb 11, 2024

#531
I'm not sure where to add tests for this. Also, is the reset of start really required?

@ashishnitinpatil
Copy link
Contributor

Created a PR for this - #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants