Python doctest library

## basic usage

“`
“””
>>> print ‘hello’
hello
“””

doctest.testmod()
“`

## be verbose

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

## traps

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.

About 逸飞

后端工程师

发表评论

电子邮件地址不会被公开。 必填项已用*标注