PDB won't stop inside pytest code, will stop in first function call

30 views Asked by At

If I define a pytest test like so:

from my_app.main import some_function

def test_example():
    breakpoint()
    foo = 'bar'
    some_function()

Then pdf will stop at the beginning of some_function instead of at foo = 'bar'. How can I get it to stop inside the test code?

Here is how I am running pytest:

pytest /app/tests/test_example.py::test_example --cov=/app/src/
1

There are 1 answers

0
user3207874 On

Apparently, some PyTest plugins can interfere with pdb. Removing the --cov flag fixed the issue and I am now able to stop on breakpoints inside tests.

pytest /app/tests/test_example.py::test_example