[Python-Dev] Proposed unittest changes

Ron Adam rrr at ronadam.com
Wed Jul 16 14:13:20 CEST 2008



Raymond Hettinger wrote:
> From: "Ben Finney" <ben+python at benfinney.id.au>
>> Right, so I'm putting up a separate PEP just for the renaming. Should
>> be arriving on this list soon.
> 
> I would like to work with you or someone else who is interested
> on an alternative PEP for a separate, simpler test module
> using the py.test syntax.  That is much simpler to learn and use.
> Instead of self.assertIsNot and whatnot, you write:
>   assert a is not b
> No need for tons of word-by-word spellings on things we already
> have syntax for.  Almost anyone who has used py.test can attest
> its syntax is much more natural, easy to learn, easy to both
> read and write, and is much lighter weight.  I think some variant
> of py.test could be done that is compatable with unittest
> and the did not have the "magic" present in earlier versions of py.test.
> I wrote a recipe (somewhat rough and incomplete) that shows how
> easily this could be done:
> 
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/572194
> 
> Raymond

+1 for a simpler testing module.

Just letting you know there is interest in a lighter weight testing suite.

Looking at the unittest discussions, it doesn't look like it is getting 
easier to use, but more complex. Py.test looks very interesting, especially 
the test discovery parts.  I also agree we don't need special methods for 
every variation of assertedness.


I've been thinking that a few decorators may go a long way to making 
writing tests easy.  It also reduces the level of indentation needed.

Ron










More information about the Python-Dev mailing list