arrow icon indicating copy to clipboard operation
arrow copied to clipboard

FR: Implement context manager to mock time.

Open OrangeTux opened this issue 10 years ago • 3 comments

I just stumbled upon dmc, a different library for handling dates and times in Python. With this library you are able to mock the current time. It could be like this:

with arrow.mock('2013-05-11T21:23:58.970460+00:00'):
    assert arrow.now() == arrow.get('2013-05-11T21:23:58.970460+00:00')

This feature would be very useful for unit testing methods which use arrow.now() or a related method.

OrangeTux avatar Aug 07 '14 07:08 OrangeTux

I'd definitely consider this if you or anyone else would like to send me a PR.

crsmithdev avatar Aug 07 '14 20:08 crsmithdev

Ok, I'll do my best. But it could take a while.

OrangeTux avatar Aug 07 '14 20:08 OrangeTux

@andrewelkins Is a pull request still desired for this? freezegun's freeze_time method can be an alternative to mock time.

rgbongocan avatar Nov 09 '17 04:11 rgbongocan