pd.Timestamp.now() not mocked
See original GitHub issueCode for replication:
import datetime
import pandas as pd
import freezegun
with freezegun.freeze_time("2011-01-01"):
print(pd.Timestamp.now())
print(datetime.datetime.now())
Expected output:
2011-01-01 00:00:00
2011-01-01 00:00:00
Actual output:
2019-05-20 17:14:03.781282
2011-01-01 00:00:00
Version information:
freezegun==0.3.11
pandas==0.24.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to test pandas DataFrame with current timestamp
Then, you can use an assert statement to check if the two DataFrames are equal. import unittest import pandas as pd from unittest.mock...
Read more >pandas.Timestamp.now — pandas 1.5.2 documentation
Return new Timestamp object representing current time local to tz. Parameters ... pd.Timestamp.now() Timestamp('2020-11-16 22:06:16.378782').
Read more >How to Mock the Current Date and Time in Python
If you're testing Python code that relies on the current date or time, you will probably want to mock time to test different...
Read more >Using pandas to_datetime with timestamps - GeeksforGeeks
The pd.to_datetime() method with a timestamp as argument and unit='ms', calculating the number of milliseconds to the Unix epoch start.
Read more >Python Mock.timestamp Examples
Mock.timestamp extracted from open source projects. ... Timestamp(now - datetime.timedelta(hours=2)) strike2.timestamp = pd.Timestamp(now) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1 on this issue
This works in time-machine: https://pypi.org/project/time-machine/
(Built as an alternative to freezegun, history post)