On Sat, Jul 25, 2020 at 10:15:16PM -0500, Henry Lin wrote: > Hey all, > > 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? assertEqual(actual, expected) 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? -- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TDLFBURVX4N4JJP4ELIRLKULR775VNOY/ Code of Conduct: http://python.org/psf/codeofconduct/