Branko Čibej wrote: > On 18.12.2014 03:48, Alexey Neyman wrote: >> Any objections to the attached fix? >> >>> + def _assertListEqual(self, l1, l2): >>> + """Poor man's replacement for assertListEqual, available in Python >>> 2.7+""" >>> + self.assertEqual(len(l1), len(l2)) >>> + for i in range(0, len(l1)): >>> + self.assertEqual(l1[i], l2[i]) > > Perhaps just: > > map(self.assertEqual, l1, l2) > > and I would prefer subclassing to instance method injection.
According to https://docs.python.org/2/library/unittest.html#type-specific-methods "The assertEqual() method dispatches the equality check for objects of the same type to different type-specific methods. These methods are already implemented for most of the built-in types..." And under addTypeEqualityFunc it says: "The list of type-specific methods automatically used by assertEqual() are summarized in the following table. Note that it’s usually not necessary to invoke these methods directly." So isn't it best just to call assertEqual() in the first place? It sounds like that will delegate to assertListEqual() if available, and work in a simpler older way otherwise. - Julian

