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

Add auto_tick_seconds #14

Closed
wants to merge 1 commit into from
Closed

Add auto_tick_seconds #14

wants to merge 1 commit into from

Conversation

adamchainz
Copy link
Owner

No description provided.

@adamchainz adamchainz mentioned this pull request May 29, 2020
4 tasks
@adamchainz
Copy link
Owner Author

I'm closing this for now. I'll add it, or an alternative API, if someone asks for it. But I think the use in freezegun is probably quite minimal.

@adamchainz adamchainz closed this Jul 21, 2020
@adamchainz adamchainz deleted the auto_tick_seconds branch June 2, 2022 10:49
@adamchainz adamchainz restored the auto_tick_seconds branch June 2, 2022 10:49
@adamchainz adamchainz deleted the auto_tick_seconds branch June 2, 2022 10:49
@alexciuba
Copy link

alexciuba commented Oct 12, 2024

Any chance of opening this one back up and merging it? I find this feature of freezegun quite useful as it helps make tests more reproducible.

To give you some context about the use case, I am trying to reduce flakiness on an existing test suite with thousands of tests. Part of this involves enabling time-machine across the whole test suite using a session scoped fixture. There are quite a few cases where tests don't expect time to be completely frozen, and fail as a result. However if I use the default tick=True behaviour, then it's basically the same as not having mocked time in the first place. So the consistent change in time between runs provided by auto_tick_seconds is exactly what I'm looking for here.

As an alternative API maybe tick can also be an int or float. That might remove some ambiguity in the API. Since with the additional parameter you could technically do something like time_machine.travel(0, tick=False, auto_tick_seconds=1.0) where the expected behaviour isn't immediately clear.

Also thanks for all the time you've dedicated to this project. I recently migrated from freezegun, and it is a significant improvement.

@adamchainz
Copy link
Owner Author

Please don't post on old issues and PRs, but open a new one instead.

However if I use the default tick=True behaviour, then it's basically the same as not having mocked time in the first place.

I don't really understand this assertion. You can make each test start at the mocked time, no? Then from the first read of the clock, they start progressing through time at a real rate, rather than a fake one.

Please reply on a new issue, with an example test file.

Also thanks for all the time you've dedicated to this project. I recently migrated from freezegun, and it is a significant improvement.

I'm glad you have enjoyed it.

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

Successfully merging this pull request may close these issues.

2 participants