How do I run python's trace with pytest?

不想你离开。 提交于 2020-05-29 09:36:21

问题


I am trying to run a trace on a program that is executed with pytest. I am trying the command

python3 -m trace -t  pytest test_one.py 

but it is giving me

Cannot run file 'pytest' because: [Errno 2] No such file or directory: 'pytest'

as I am assuming trace.py is expecting a file. I saw this similar question but I'm a bit struggling to understand what is supposed to mean - is it supposed to be the executable file for pytest itself (I actually don't see where that is on my computer, I found a folder to a main.py and init.py but I can't seem to see some executable), or something else?


回答1:


As stated in a comment to the referenced question, you have to substitute pytest by the actual path to the pytest executable:

python -m trace -c -m -C . <pytest_script_absolute_path> test_script.py

Under *nix, you should be able to localize the pytest executable using which pytest, under Windows using where pytest (thanks to @hoefling for reminding me of that).



来源:https://stackoverflow.com/questions/60381237/how-do-i-run-pythons-trace-with-pytest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!