【问题标题】:How to run the doctest for a single function in python3?如何在 python3 中为单个函数运行 doctest?
【发布时间】:2021-07-16 09:59:28
【问题描述】:

如何使用命令行仅在 python 中为单个函数运行 doctest?我可以 python3 -m doctest -v main.py 但这将运行 main.py 中的所有文档测试。如何指定一个函数来调用 doctest?

【问题讨论】:

    标签: python doctest


    【解决方案1】:

    这取决于运行 doctests 的 main.py 中的代码。您可以通过调用 doctest.run_docstring_examples() 将该代码更改为 test a specific function

    但是,当该代码运行 doctest.testmod() 时,您不能从命令行将测试限制为单个函数。

    【讨论】:

    • 谢谢,好像没有办法从命令行做到这一点!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多