Reputation: 41
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?
Upvotes: 3
Views: 1291
Reputation: 1809
We can use the --module
flag to trace pytest as a module:
python -m trace -t --module pytest -- path/to/pytests --pytest-arg
As usual, the --
signals that the remaining arguments are positional, allowing you to pass --flags or -flags to pytest.
Upvotes: 0
Reputation: 16855
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_executable_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).
Upvotes: 4