美文网首页原理和语言
The Python Standard Library - De

The Python Standard Library - De

作者: 左心Chris | 来源:发表于2019-07-30 17:43 被阅读0次

    3 doctest

    3.0 Intro

    1. 为了最新测试module’s docstrings are up-to-date
    2. 为了回归测试regression testing by verifying that interactive examples from a test file or a test object work as expected
    3. 为了写指南文档To write tutorial documentation for a package, liberally illustrated with input-output examples.
      官方samples:https://github.com/python/cpython/blob/3.7/Lib/test/test_doctest.py

    3.1 Simple Usage in Docstrings

    # module M
    if __name__ == "__main__":
        import doctest
        doctest.testmod()
    python M.py # only fail
    python M.py -v # all(verbose)
    

    doctest then examines docstrings in module M.

    3.2 Simple Usage in a Text File

    import doctest
    doctest.testfile("example.txt")
    

    相关文章

      网友评论

        本文标题:The Python Standard Library - De

        本文链接:https://www.haomeiwen.com/subject/gnigrctx.html