让每个 运行 的 python 解释器自动调用 `coverage`?

Make each run of python interpreter automatically call `coverage`?

我有 test.sh 在许多不同的脚本上运行 python 命令。有没有办法为每个 python 调用发出 coverage -a 而无需在每个命令前加上 coverage -a?

请参阅有关子流程测量的 coverage.py 文档,了解在启动时自动调用覆盖率的方法 Python: http://coverage.readthedocs.io/en/latest/subprocess.html 。这需要一些小技巧。

在 shell 脚本中使用别名可能更容易。对于 "nosetests" 之类的内容,将其更改为 "python -m nose"。