[英]How to run the doctest for a single function in python3?
How do I run the doctest for only a single function in python using the command line?如何使用命令行为 python 中的单个 function 运行 doctest? I can python3 -m doctest -v main.py
but this will run all the doctests in main.py.我可以python3 -m doctest -v main.py
但这将运行 main.py 中的所有 doctests。 How do I specify one function to call the doctest on?如何指定一个 function 来调用 doctest?
That depends on the code in main.py that runs the doctests.这取决于运行 doctests 的 main.py 中的代码。 You can change that code to test a specific function by calling doctest.run_docstring_examples()
.您可以通过调用doctest.run_docstring_examples()
更改该代码以测试特定函数。
When that code runs doctest.testmod()
however, you cannot limit testing to a single function from the command line.但是,当该代码运行doctest.testmod()
时,您不能将测试限制为来自命令行的单个函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.