question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Freezegun breaks isinstance() checks on existing objects.

See original GitHub issue

If you have a date object that was created before freezing time, you cannot then do an isinstance check against datetime.date:

>>> date = datetime.date.today()
>>> freezer = freeze_time('2011-01-01')
>>> freezer.start()
>>> isinstance(date, datetime.date)
False
>>>

This is because at the point you call the isinstance, the value of datetime.date is <class 'freezegun.api.FakeDate'>, of which date is not a subclass.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
schinckelcommented, Feb 16, 2018

I’m not sure. It seems that @spulec hasn’t been on GitHub much lately. He’s likely the only one who can merge, and push releases. It is possible to reference a git-commit in a requirements.txt: you may have to do that until he has time to merge/push.

0reactions
boxedcommented, Feb 19, 2019

I am also a contributor that can merge. Unfortunately I can’t cut releases to pypi at this time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to mock datetime.date.today(), but not working
This one has advantage of not breaking type checking with isinstance(d, datetime.date) . import mock def fixed_today(today): from datetime import date class ...
Read more >
python/typing - Gitter
Hello. I have a question on enum and typing. If I overload some function for each available enum values as parameter and then...
Read more >
Digging into a Test Failure – A blog for Ted - Ted Mielczarek
I realized that if the database connection was created before any code imported the freezegun module the workaround freezegun was attempting to ...
Read more >
How to work with dates and time with Python | Bloomberg LP
When trying to make things work with the datetime module, most Python users have faced a point when we resort to guess-and-check until...
Read more >
pytest Documentation - Read the Docs
2.17 How to use pytest with an existing test suite . ... Note: Calling pytest.main() will result in importing your tests and any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found