如何分析毒性?

gue*_*tli 2 python profiling tox

我通过 tox 运行一个特定的测试用例:

tox -e myenv foo.tests.test_foo.SomeTestCase
Run Code Online (Sandbox Code Playgroud)

这需要 30 秒。

测试本身非常简单且快速。但在测试开始运行之前似乎发生了很多事情。

我如何跟踪/分析测试运行之前发生的事情?

我想仅分析 tox 不会有帮助,因为 tox 没有多大作用。Tox 会产生耗时过长的子进程。

Yet*_*eti 5

tox 4在通过两级详细级别时打印出时间戳。所以我的建议是安装 tox 4 然后执行tox -vvv r -e myenv --foo.tests.test_foo.SomeTestC.

附言。您可以做的一个可能的大事情是通过在 sdist 构建上启用 Wheel 构建(仅在 tox 4 中支持),因为目前使用 pip 安装 sdist 非常昂贵,因为需要设置一个隔离的构建环境:

[testenv]
package = wheel
# below settings only applies if you don't have a c extension
wheel_build_env = .pkg
Run Code Online (Sandbox Code Playgroud)

附言。我是毒物作者/维护者。