A better unittest

Andrew Bennetts andrew-pythonlist at puzzling.org
Thu Apr 17 11:28:15 CEST 2003

On Wed, Apr 16, 2003 at 02:50:11PM -0600, Steven Taschuk wrote:
> Quoth Terry Reedy:
>   [...]
> > I like having the actual values too.  It should make debugging an
> > unexpected failure easier.  But what if each value is more that a few
> > bytes?  Example (from my future plans): two lists of all permutations
> > of range(8), one produced by an obvious recursion and the other by a
> > much less obvious iteration.
> Now and then I replace
>     self.assertEquals(longlist1, longlist2)
> with
>     map(self.assertEquals, longlist1, longlist2)
> It's not quite ideal; in some cases it would be nice to see the
> index of the mismatch too, for example.

map(self.assertEquals, enumerate(longlist1), enumerate(longlist2))

[Requires Python 2.3, of course]


More information about the Python-list mailing list