python doctest模块学习笔记
2011-12-11 22:11
113 查看
You can force verbose mode by passing verbose=True to testmod()不用在
python x.py -v后面加-v显示测试打印信息
The module docstring, and all function, class and method docstrings are searched. Objects imported into the module are not searched.
检查模块,函数,方法,类的docstrings。导入的模块不检查。
如果模块定义__test__会检查,测试里面定义的项
大多数情况下哦复制粘贴IDLE中的会话(seesion)即可。但python不会去尝试特制的仿真器。
Any expected output must immediately follow the final '>>> ' or '... ' line
containing the code, and the expected output (if any) extends to the next '>>> ' or
all-whitespace line.
所有期待的输出必须紧跟包含代码的'>>>'或者'...'。输出后面紧跟'>>> ' 或者空格。
Expected
output cannot contain an all-whitespace line, since such a line is taken to signal the end of expected output. If expected output does contain a blank line, put <BLANKLINE> in
your doctest example each place a blank line is expected.
输出不能是全空白行,如果有这样的输出用<BLANKLINE> 代替。
All
hard tab characters are expanded to spaces, using 8-column tab stops. Tabs in output generated by the tested code are not modified.
所有硬编码的Tab被展开成8列的空格符,测试代码产生的Tab不会被修改。
doctest在测试时复制被测试module的globals
你可以在测试代码中用module的变量。但不能用别的docstring的变量。
输出exception时开头要:
中间被忽略
后面跟eccp的详细信息NameError: name 'a' is not defined,可以是多行的。
python x.py -v后面加-v显示测试打印信息
The module docstring, and all function, class and method docstrings are searched. Objects imported into the module are not searched.
检查模块,函数,方法,类的docstrings。导入的模块不检查。
如果模块定义__test__会检查,测试里面定义的项
How are Docstring Examples Recognized?:
大多数情况下哦复制粘贴IDLE中的会话(seesion)即可。但python不会去尝试特制的仿真器。Any expected output must immediately follow the final '>>> ' or '... ' line
containing the code, and the expected output (if any) extends to the next '>>> ' or
all-whitespace line.
所有期待的输出必须紧跟包含代码的'>>>'或者'...'。输出后面紧跟'>>> ' 或者空格。
Expected
output cannot contain an all-whitespace line, since such a line is taken to signal the end of expected output. If expected output does contain a blank line, put <BLANKLINE> in
your doctest example each place a blank line is expected.
输出不能是全空白行,如果有这样的输出用<BLANKLINE> 代替。
All
hard tab characters are expanded to spaces, using 8-column tab stops. Tabs in output generated by the tested code are not modified.
所有硬编码的Tab被展开成8列的空格符,测试代码产生的Tab不会被修改。
25.2.3.3. What’s the Execution Context?
doctest在测试时复制被测试module的globals你可以在测试代码中用module的变量。但不能用别的docstring的变量。
输出exception时开头要:
Traceback (most recent call last): Traceback (innermost last):
中间被忽略
后面跟eccp的详细信息NameError: name 'a' is not defined,可以是多行的。
相关文章推荐
- python __doc__回答
- html5lib-python doc
- python基础---- __getattribute__----__str__,__repr__,__format__----__doc__----__module__和__class__
- python中的文档字符串(docString)
- python __doc__
- Ubuntu下使用python读取doc和docx文档的内容方法
- python中的DocStrings
- 通过Python处理Android API Doc离线访问
- Python&nbsp;DOCStrings示例程序
- GoodZhang在学Python(五)--Python中的文档字符串(docStrings)
- Python编程之Python doctest
- 如何在命令行模式下查看Python帮助文档---dir、help、__doc__
- http://www.python.org/doc/
- Python doc v2.7.6 ------ 5.2.10.1. Generator-iterator methods
- Python实现doc转化pdf
- Python实现将DOC文档转换为PDF的方法
- 解决python大批量读写.doc文件的问题
- Python语言中的__name__和__doc__
- python 编程中的__doc__的使用
- python学习[1]_python中的__name__属性和__doc__属性使用示