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).
Videos
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).
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.
» pip install pytest-trace
it's real simple: put an assert 0 where you want to start debugging in your code and run your tests with:
py.test --pdb
done :)
Alternatively, if you are using pytest-2.0.1 or above, there also is the pytest.set_trace() helper which you can put anywhere in your test code. Here are the docs. It will take care to internally disable capturing before sending you to the pdb debugger command-line.
I found that I can run py.test with capture disabled, then use pdb.set_trace() as usual.
> py.test --capture=no
============================= test session starts ==============================
platform linux2 -- Python 2.5.2 -- pytest-1.3.3
test path 1: project/lib/test/test_facet.py
project/lib/test/test_facet.py ...> /home/jaraco/projects/project/lib/functions.py(158)do_something()
-> code_about_to_run('')
(Pdb)
» pip install pytctracer