[Python-Dev] Proposed unittest changes

Guido van Rossum guido at python.org
Thu Apr 17 19:01:51 CEST 2008

On Thu, Apr 17, 2008 at 7:59 AM, Michael Foord
<fuzzyman at voidspace.org.uk> wrote:
>  By etc I assume you mean:
>    assertLessThan
>    assertGreaterThan
>    assertLessThanOrEquals
>    assertGreaterThanOrEquals

These names are used here:

assertListEqual(self, list1, list2, msg=None):
assertIn(self, a, b, msg=None):
assertNotIn(self, a, b, msg=None):
assertDictEqual(self, d1, d2, msg=None):
assertSameElements(self, expected_seq, actual_seq, msg=None):
assertMultiLineEqual(self, first, second, msg=None):
assertLess(self, a, b, msg=None):
assertLessEqual(self, a, b, msg=None):
assertGreater(self, a, b, msg=None):
assertGreaterEqual(self, a, b, msg=None):
assertCommandSucceeds(self, command):
assertCommandFails(self, command, regexes):

I can look into making those open source, but it'd probably more
efficient use of everyone's time to just reimplement them; most are
only a few lines. You can skip the assertCommand* ones, they're for
testing shell commands.

>  Did you look at the other proposals?

Not yet.

>  * Decorator to make a function a TestCase

But what about TOOWTDI?

>  * Convenience RunTests functions taking modules, suites and TestCases and
> running them

If it addresses the most common reason why people have to hack this
stuff, by all means.

>  * Improved messages for assertEquals and assertNotEquals when an explicit
> message is passed in


>  * Improved message when comparing lists/tuples with assertEquals

I'd say do that in assertListEqual

>  * The additional asserts that I suggested (In/NotIn, RaisesWithMessage,
> Is/NotIs)

Sure. Google has In/NotIn

>  I think that there is still work I can do on the docs even before any grand
> renaming...

Go ahead!

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list