Open kurtbrose opened 2 months ago
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?)
Also, thanks very much for maintaining this open source library! I appreciate your generosity.
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):