You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just spent an hour debugging a weird interaction with datetime != datetime the first time a particular branch of code got run inside a freezegun block.
My fix (after much fiddling around) was issubclass(type_, datetime) instead of type_ == datetime.
I notice that FakeDatetimeMeta overrides __instancecheck__ and __subclasscheck__ to appear to be a datetime. Has it also been discussed overriding __eq__?
I did a quick search but didn't find any prior issues on this topic. If this is a repeat, maybe it would be a good idea to add a comment or docstring explaining why overriding __eq__ is hard? (Maybe it breaks with older python?)
I just spent an hour debugging a weird interaction with
datetime != datetime
the first time a particular branch of code got run inside afreezegun
block.My fix (after much fiddling around) was
issubclass(type_, datetime)
instead oftype_ == datetime
.I notice that
FakeDatetimeMeta
overrides__instancecheck__
and__subclasscheck__
to appear to be a datetime. Has it also been discussed overriding__eq__
?Here's what the class would look like with the new method:
https://github.com/spulec/freezegun/blob/master/freezegun/api.py#L355-L362
Here's fiddling around at the REPL to double-check overriding
__eq__
on a metaclass works as expected (at least in newer Python 3):The text was updated successfully, but these errors were encountered: