Mock Pandas Timestamp now/utcnow/today methods #426
+62
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Patch to solve #298. Freeze_time patches the pandas Timestamp, now, utcnow, and today methods if pandas is available on the system (i.e. an import pandas call does not fail) and has no effect if pandas is not installed.
The mocks are generated by wrapping the equivalent calls from FakeDatetime in a Timestamp constructor, so ticking/etc. functionality from the original class should flow directly. However, the mocked return value of Timestamp.now, Timestamp.today, and Timestamp.utcnow is currently Timestamp, but not FakeDatetime. If the latter is necessary (e.g. if it's contracted that any freezegun'd value is always a FakeDate/FakeDatetime) I can revise the PR.