[TIP] unittest2.util

Michael Foord fuzzyman at voidspace.org.uk
Mon Sep 27 13:54:24 PDT 2010

  On 27/09/2010 19:47, Matthew Woodcraft wrote:
> 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).
They're so trivial it would be better to reimplement than reuse. :-)

> 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.
Ok - that's a reasonable request. Can you raise an issue for it?


> The other is unorderable_list_difference.
That's in unittest in Python 2.7 - so I doubt it will be removed / 
moved. :-)

> 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?)
I don't understand what you mean by this. What are you trying to compare 
and why is the output not good enough?

Hmmm... sorted_list_difference is not used anymore, in fact I'm not sure 
why it was in a released version of Python in the first place. There was 
a variant of these in Python 3.1, but they were buggy and improved. I 
wouldn't rely on sorted_list_difference continuing to exist - it should 
be deprecated and removed.


> -M-
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python


READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.

More information about the testing-in-python mailing list