how to get which statements are missed in python test coverage

If you check the documentation for reporting in pytest-cov, you can see how to manipulate the report and generate extra versions.

For example, adding the option --cov-report term-missing you'll get the missing lines printed in the terminal.

A more user friendly option, would be to generate an html report by usign the --cov-report html option. Then you can navigate to the generated folder (htmlcov by default) and open the index.html with your browser and navigate your source code where the missing lines are highlighted.


In addition to the answer from Ignacio, one can also set show_missing = true in .coveragerc, as pytest-cov reads that config file as well.