Jens Vagelpohl wrote:
Hash: SHA1

On 27 Dec 2006, at 16:16, Tres Seaver wrote:
Rocky Burt wrote:
On Wed, 2006-27-12 at 11:46 +0100, Jens Vagelpohl wrote:
P.S.: I _hate hate hate_ doctests ;)


I won't speak for Jens, but I find they have two serious drawbacks when
used as *unit tests* (as opposted to quasi-functional tests with narrative):

  - Tests dont run in isolation from one another (this is why I say

  - The contortions required to get testable output printed often
    obscure the intent of the test itself.

From painful experience with the customer work right now, and from the work on the CMF branch to convert tools to utilities I'll add that they make debugging a lot harder (where can I step into and through the test code with pdb as I normally do?) and the fact that they don't just stop executing when an error is encountered like a normal unit test does. They continue, usually spewing miles and miles of text, and it's really annoying to scroll back screen after screen after screen to find the real problem.

I agree with the pdb problem. I tend to use them either to explain narratives about how code works, for functional tests with zope.testbrowser, and sometimes they just "feel" right for the thing to be tested, but I quickly came off using them for everything.

To only see the first test failure (it'll continue to execute regardless, because you may have cleanup code that needs to run after...) in the output, you can do this, which I always do:

import unittest
import doctest

from some.module import test_module

optionflags = doctest.REPORT_ONLY_FIRST_FAILURE | doctest.ELLIPSIS

def test_suite():
    suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(test_module, optionflags=optionflags))
    return suite

Zope-CMF maillist  -

See for bug reports and feature requests

Reply via email to