If you’d like to debug your code/test if only it throws an error run:

$ pytest -x --pdb

This will put you into pdb on the first failure.

-x flag makes pytest stop on the first failure. If you want to invoke the pdb on every failure -I dont' think, run without x flag:

$ pytest --pdb

For more info you can look at: pytest failures

All done!