"python3 -m test" 和 "python3 -m unittest" 之间的区别
Difference between "python3 -m test" and "python3 -m unittest"
我发现我可以通过这样做在我的目录树下发现和 运行 单元测试:
python3 -m test
上面的方法有效,但是 documented method 发现和 运行 所有测试发现了数百个,包括以前的方法没有找到的新的:
python3 -m unittest
-m test
到底是什么?为什么我快速搜索后找不到关于它的文档,除了以下页面似乎是关于 CPython 的?
test
包旨在测试 Python API 本身。根据文档:
Note: The test
package is meant for internal use by Python only. It is documented for the benefit of the core developers of Python. Any use of this package outside of Python’s standard library is discouraged as code mentioned here can change or be removed without notice between releases of Python.
此文档的 link 出现在 the TOC under Development Tools 中。虽然 python3 -m test
命令发现和 运行 测试并不完全令人惊讶,但它并不是真正设计用于发现和 运行 您为自己的代码编写的测试。
我发现我可以通过这样做在我的目录树下发现和 运行 单元测试:
python3 -m test
上面的方法有效,但是 documented method 发现和 运行 所有测试发现了数百个,包括以前的方法没有找到的新的:
python3 -m unittest
-m test
到底是什么?为什么我快速搜索后找不到关于它的文档,除了以下页面似乎是关于 CPython 的?
test
包旨在测试 Python API 本身。根据文档:
Note: The
test
package is meant for internal use by Python only. It is documented for the benefit of the core developers of Python. Any use of this package outside of Python’s standard library is discouraged as code mentioned here can change or be removed without notice between releases of Python.
此文档的 link 出现在 the TOC under Development Tools 中。虽然 python3 -m test
命令发现和 运行 测试并不完全令人惊讶,但它并不是真正设计用于发现和 运行 您为自己的代码编写的测试。