[TIP] Best way to do setup/teardown on a per-test basis using doctest?

Michael Foord fuzzyman at voidspace.org.uk
Sat Jun 30 15:17:23 PDT 2007

Brett Cannon wrote:
> There was an email to python-3000 recently from someone saying that we
> should convert all unit tests for Python and its standard library over
> to doctest.  

Hello Brett,

I'm sure someone will answer your specific question, but I hope the 
suggestion to convert *all* Python tests over to doctest is not being 
accepted without debate.

Whilst I'm sure what you want can be done with doctest, it seems to 
offer little advantage in the general case other than forcing your tests 
to be inside strings and use lots of angle brackets!

I realise there are those on this list that prefer doctest, but I 
disagree. Doctest is great for embedding executable examples into 
documentation, but not so well suited for large test suites. :-)

I also wonder whether it would be harder to port doctest to new 
implementations of Python - making it harder for them to test compatibility.


More information about the testing-in-python mailing list