[TIP] unittest2.util

Matthew Woodcraft matthew at woodcraft.me.uk
Mon Sep 27 11:47:46 PDT 2010


Michael Foord  <fuzzyman at voidspace.org.uk> wrote:
> Which functions [in unittest.util] are you interested in? If they are
> non-trivial and generally useful or necessary then I can export them
> at the top level. Importing from the top level allows me to move
> things around without breaking your code.

There are two things I'm using.

First, safe_str (or safe_repr). But I think what I'd really like here is
for something like TestCase._formatMessage to be public: it seems to me
that pretty much anyone writing a custom TypeEqualityFunc is going to
want this facility, and it's bit of a shame to have to reimplement it.

The other is unorderable_list_difference. In this case, I think what I'd
really like is a (variant of) assertItemsEqual which always uses the
form of output it chooses for 'unsortable' items, as I find it's usually
easier for me to read. (I see there's a sorted_list_difference in util
too. Is that used for anything?)

-M-




More information about the testing-in-python mailing list