test_doctest.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:oil 作者: oilshell 项目源码 文件源码
def old_test1(): r"""
>>> from doctest import Tester
>>> t = Tester(globs={'x': 42}, verbose=0)
>>> t.runstring(r'''
...      >>> x = x * 2
...      >>> print x
...      42
... ''', 'XYZ')
**********************************************************************
Line 3, in XYZ
Failed example:
    print x
Expected:
    42
Got:
    84
TestResults(failed=1, attempted=2)
>>> t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2')
TestResults(failed=0, attempted=2)
>>> t.summarize()
**********************************************************************
1 items had failures:
   1 of   2 in XYZ
***Test Failed*** 1 failures.
TestResults(failed=1, attempted=4)
>>> t.summarize(verbose=1)
1 items passed all tests:
   2 tests in example2
**********************************************************************
1 items had failures:
   1 of   2 in XYZ
4 tests in 2 items.
3 passed and 1 failed.
***Test Failed*** 1 failures.
TestResults(failed=1, attempted=4)
"""
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号