使用 pytest 运行 trace.py [英] Run trace.py with pytest
问题描述
我试图在运行 pytest
时使用 trace.py
获得覆盖率.我知道 pytest
有自己的覆盖插件 pytest-cov
但限制(每行执行的次数不可用)不允许我现在使用它.coverage.py
I'm trying to get coverage using trace.py
when running pytest
. I know that pytest
has its own coverage plugin pytest-cov
but restrictions (number of times each line is executed is unavailable) do not allow me to use that right now. The same for coverage.py
我正在尝试这个命令:python3.4 -m trace -c -m -C .pytest test_script.py
test_script.py
:
class TestScript():
def test_print(self):
print ('Hello')
输出为:
nikhilh$ python3.4 -m trace -c -m -C . pytest test_script.py
pytest: Cannot run file 'pytest' because: [Errno 2] No such file or directory: 'pytest'
trace.py
显然在其参数中需要一个文件而不是另一个模块.如何修改此命令以使 trace.py
与 pytest
一起使用?
trace.py
obviously expects a file in its arguments and not another module. How can I modify this command to get trace.py
working with pytest
?
我能够找到一种方法来完成这项工作
I was able to find a way to get this done
nikhilh$ python3.4 -m trace -c -m -C .<pytest_script_absolute_path>test_script.py
推荐答案
无意中看到 David 的评论,所以这里是我当时使用的答案:
Came across David's comment, so here's the answer that I used at that time:
python3.4 -m trace -c -m -C .<pytest_script_absolute_path>test_script.py
这篇关于使用 pytest 运行 trace.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!