问题
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