[Python-Dev] Proposed unittest changes
fuzzyman at voidspace.org.uk
Tue Jul 15 01:43:12 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.
However, to provide readable output for errors in even simple tests
(like a == b) py.test does magic with stack frames and code objects - in
order to discover the objects being compared.
As this relies on what are essentially implementation details of the
Python interpreter it means that some implementations (specifically
IronPython which doesn't have Python stack frames and only a minimal
representation of frame objects) will never be able to run it.
I think it would be a bad idea to move *Python testing* itself over to a
framework like this.
I personally find unittest pretty readable, the feature most lacking is
autodiscovery of tests which nose does seem to provide very well
although I haven't used it yet.
> 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:
> Python-Dev mailing list
> Python-Dev at python.org
More information about the Python-Dev