doctest -> unittest

Michele Simionato mis6 at
Mon Aug 4 23:34:44 CEST 2003

Just today I have experimented with the new doctest -> unittest
feature of Python 2.3. It works quite well, but I find the output way
too much noisy. For instance

def example():
    >>> 1+1

import doctest,unittest,__main__
suite = doctest.DocTestSuite(__main__)

gives the following result:

ERROR: doctest of __main__.example
Traceback (most recent call last):
  File "/usr/local/lib/python2.3/", line 413, in runTest
  File "/usr/local/lib/python2.3/", line 1358, in runit
    _utest(tester, name, doc, filename, lineno)
  File "/usr/local/lib/python2.3/", line 1308, in _utest
    raise DocTestTestFailure('Failed doctest test for %s\n'
DocTestTestFailure: Failed doctest test for __main__.example
  File "", line 2, in example

Failure in example: 1+1
from line #1 of __main__.example
Expected: 1
Got: 2

Ran 1 test in 0.013s

FAILED (errors=1)

It is too long for my taste, is there a way of turning off the
traceback which is confusing more than useful?


More information about the Python-list mailing list