Opening pdb shell on failed test under tox
I start to work on feature for Molecule, and their tox configuration is too big for me to understand properly. One problem I found that I can’t control pytest.
After some thoughts and experiments I found a way to pass command line parameters to pytest.
Inside of their tox.ini
file there is a line:
commands =
...
python -m pytest {env:_EXTRAS} {env:PYTEST_ADDOPTS:} {posargs}
Thas posargs is the thing I need. Turned out, it’s a tox feature.
Together with well-known trick of having --
to terminate special handing of options, we can pass whatever we want:
tox -e py -- --pdb -k exec
This passes --pdb -k exec
directly to pytest.
As bonus, I can limit tests scope and run only tests I’m worried about (-k
) instead of 400+ in a testsuite.