FR: Implement context manager to mock time.
- Dominant language
- Python
- Stars
- 9.1k
- Forks
- 784
- PR merge metrics
- No merged PRs in 30d
Description
I just stumbled upon [dmc](https://github.com/rhettg/dmc), a different library for handling dates and times in Python. With this library you are able to [mock the current time](https://github.com/rhettg/dmc#testing). 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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the implementations of arrow.now() and arrow.get(), then review the surrounding tests for date and time behavior. Define the arrow.mock() context manager around the example in the issue, and verify that arrow.now() returns the mocked timestamp only within the context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100