-
-
Notifications
You must be signed in to change notification settings - Fork 34
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 shift() method #27
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks !
So I'm thinking this through a bit. I am not sure if it's wise to pursue 100% the same API as freezegun here because it's a bit confusing. The name I'm also not sold on the default being 1 second. When is that useful case? Wouldn't it better to be explicit, for the sake of writing '1' in tests to make it clear how much time is moving by? I'm gonna mull this over for a little bit, it's especially a question as to whether I want this library to have the exact same API as freezegun, or just to support the same use cases. There's some support for copying the core technique over to freezegun so I might be free-er to use a different API here. |
Totally agree, it is confusing to have two different things called What do you think of these? def test_coordinates_add_timedelta():
with time_machine.travel(EPOCH, tick=False) as coordinates:
coordinates += dt.timedelta(seconds=1)
assert time.time() == EPOCH + 1
def test_coordinates_set_exact_time():
destination_dt = dt.datetime(2000, 1, 1)
with time_machine.travel(EPOCH, tick=False) as traveller:
traveller.move_to(destination_dt)
# or maybe even? :)
traveller >> destination_dt
assert time.time() == destination_dt.timestamp() |
I don't like operator overloading, it is a bit implicit. Perhaps |
I like both |
Co-authored-by: alex-verve <alex.subbotin@pollen.co>
I've gone with |
Co-authored-by: alex-verve <alex.subbotin@pollen.co>
Co-authored-by: alex-verve <alex.subbotin@pollen.co>
refs #20