can't freeze `datetime.now()`
See original GitHub issueI decorated a test, and this test will call a func, take a look at the output:
somehow it successfully froze datetime.today()
but not datetime.now()
this is more obvious:
import datetime as dtmodule
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:7
Top Results From Across the Web
Trying to mock datetime.date.today(), but not working
Trying to mock datetime.date.today(), but not working · 1. Docs of the mock library: voidspace.org.uk/python/mock/examples.html#partial-mocking · 2. freezegun · 1.
Read more >Stop Using datetime.now! | Haki Benita
This test will pass today, but it will fail on any other day. Another way to test the function is this: # Bad...
Read more >Freezegun - Real Joy For Fake Dates In Python - PyBites
Freezegun is a library for mocking Python datetimes. It does one thing, does it well, and lets you get on with your life....
Read more >Date and time in Google Sheets - Ablebits
Fill a few cells with the required date/time/date-time values. ... NOW() - returns the current date and time to a cell.
Read more >How to work with dates and time with Python - Opensource.com
We can see how to get the current time via the now function of datetime. On the second call we pass a tzinfo...
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
Same with Django’s
timezone.now()
.@gerrywd This is strange a bit to do some calculation as default parameter value. Use sentinel (None) instead: