On Sat, Jul 25, 2020 at 10:15:16PM -0500, Henry Lin wrote:
What are thoughts about implementing an object-compare function in the unittest package? (Compare two objects recursively, attribute by attribute.)
Why not just ask the objects to compare themselves?
will work if actual and expected define a sensible `__eq__` and are the same type. If they aren't the same type, why not?
actual = MyObject(spam=1, eggs=2, cheese=3) expected = DifferentObject(spam=1, eggs=2, cheese=3)
This seems like a common use case in many testing scenarios,
I've never come across it. Can you give an example where defining an `__eq__` method won't be the right solution?