Python doctest library

Author: yifei / Created: May 30, 2017, 8:55 p.m. / Modified: May 30, 2017, 9:13 p.m. / Edit

basic usage

>>> print 'hello'


be verbose

doctest.testmod(verbose=True) or python -v


if you have unicode in your docstirng, add u to the doc string

Notes on testing classes * If it's testing the class as a whole, I'd put them in the class' docstring. * If it's testing the constructor, I'd put them in the constructor's docstring. * If it's testing a method (as it seems to be in this case), I'd actually put it them in that method's docstring.

有任何问题可以发邮件到 kongyifei (at) 讨论