2

I wrote unittest-based tests with pytest. according to this document: https://docs.pytest.org/en/7.1.x/how-to/unittest.html then I tried to run the tests by Python testing in Visual Studio Code according to this document: https://code.visualstudio.com/docs/python/testing but when I select the Debug Test icon next to that test in the Test Explorer. VS Code starts the debugger but it doesn't pause at the breakpoints. how can I make it to stop at the breakpoints?

1 Answer 1

5

According to what has been explained here, when we use "--cov" option for pytest, the VSCode doesn't stop at breakpoints. So the solution is to disable cov while debugging according to this in your VSCode launch.json add the followings:

   // your other settings are here
   {
    "name": "Debug Unit Test",
    "type": "python",
    "request": "launch",
    "justMyCode": true,
    "program": "${file}",
    "purpose": ["debug-test"],
    "console": "integratedTerminal",
    "env": {
        "PYTEST_ADDOPTS": "--no-cov"
    },
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.