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 support for dt.timedelta to travel class #298

Merged
merged 4 commits into from
Sep 19, 2023

Conversation

AgDude
Copy link
Contributor

@AgDude AgDude commented Nov 3, 2022

Adds support to pass a datetime.timedelta object to travel.

To avoid potential abuse this feature is blocked when already traveling, since the shift API would provide similar functionality and should be simpler.

This should open an API to implement #247

fixes #38

Copy link
Owner

@adamchainz adamchainz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this.

Please add docs and a release note. (And whenever opening PR's in open source.)

src/time_machine/__init__.py Outdated Show resolved Hide resolved
src/time_machine/__init__.py Outdated Show resolved Hide resolved
@AgDude AgDude requested a review from adamchainz November 8, 2022 21:44
@AgDude
Copy link
Contributor Author

AgDude commented Nov 30, 2022

@adamchainz I think your concerns have been addressed. Please clarify if I am still missing something.

@adamchainz
Copy link
Owner

Yea sure, no need to comment, I’ll get around to reviewing at some point. Busy with life stuff atm.

@adamchainz adamchainz merged commit 483907d into adamchainz:main Sep 19, 2023
@adamchainz
Copy link
Owner

Thanks for this. I merged this with a few changes. I decided that blocking use of timedelta within a travel() block wasn't worth the complexity.

#247 was fixed by calling the existing shift() method, but this is still useful for cases like "do a thing, then move a bit into the future and assert some state changed".

Released in 2.13.0.

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.

Allow passing dt.timedelta objects to travel()
2 participants