Use ipdb instead of pdb with py.test --pdb option
Asked Answered
P

2

23

I want to use ipdb instead of pdb with py.test --pdb option. Is this possible? If so, how?

Clearly, I can use import ipdb; ipdb.set_trace() in the code but that requires to run the test, watch it fail, open a file, find the point of failure in said file, write the above line, re-run the tests. Lots of hassle if I could have something that by passes all of that.

Peninsula answered 26/8, 2016 at 9:9 Comment(0)
D
8

Have you tried pytest-ipdb?

Looks like it's exactly what you are looking for?

Dunkin answered 26/8, 2016 at 18:46 Comment(1)
It was discontinued in favour of pdb++ which is good. I ended up using using pdb++.Peninsula
W
28

Use this option to set custom debugger:

--pdbcls=IPython.terminal.debugger:Pdb

It can also be included in pytest.ini using addopts:

[pytest]
addopts = "--pdbcls=IPython.terminal.debugger:Pdb"
Withrow answered 4/7, 2018 at 12:52 Comment(4)
in a file pytest.ini: [pytest] addopts = --pdbcls=IPython.terminal.debugger:PdbSkiplane
So glad to find this! Note you also need the --pdb flagKennie
If you have a more recent setup, you may need: [tool.pytest.ini_options] addopts = "--pdbcls=IPython.terminal.debugger:Pdb"Hartwell
I actually recommend --pdbcls=IPython.terminal.debugger:TerminalPdb instead, which has full tab completion.Fem
D
8

Have you tried pytest-ipdb?

Looks like it's exactly what you are looking for?

Dunkin answered 26/8, 2016 at 18:46 Comment(1)
It was discontinued in favour of pdb++ which is good. I ended up using using pdb++.Peninsula

© 2022 - 2024 — McMap. All rights reserved.