Setting "justMyCode": false makes it stop at breakpoint:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Debug Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "stopOnEntry": true,
            "justMyCode": false
        },
    ]
}
Answer from Ashish on Stack Overflow
🌐
pytest
docs.pytest.org › en › stable › how-to › failures.html
How to handle test failures - pytest documentation
To set a breakpoint in your code use the native Python import pdb;pdb.set_trace() call in your code and pytest automatically disables its output capture for that test: Output capture in other tests is not affected.
Discussions

Debugger doesn't stop at breakpoints with pytest if pytest-cov is used
Python extension for Visual Studio Code. Contribute to microsoft/vscode-python development by creating an account on GitHub. More on github.com
🌐 github.com
31
February 2, 2018
python - VSCode: Why isn't debugger stopping at breakpoints? - Stack Overflow
Note If you have the pytest-cov coverage module installed, VS Code doesn't stop at breakpoints while debugging because pytest-cov is using the same technique to access the source code being run. More on stackoverflow.com
🌐 stackoverflow.com
unit testing - Can I debug with python debugger when using py.test somehow? - Stack Overflow
If run this with normal python, ... not run it. But py.test finds functions starting with test_ and runs them for me, taking care of failed asserts etc. 2010-04-22T14:55:13.137Z+00:00 ... Fixed the link to pytest command line documentation. 2022-11-01T16:51:12.687Z+00:00 ... Although you can add breakpoints by adding ... More on stackoverflow.com
🌐 stackoverflow.com
python - Unable to debug in pycharm with pytest - Stack Overflow
All the test suite is running ok in "Debug mode" but it doesn't stop on breakpoints. I also have py.test as the default test runner. Maybe this is not important, but debugging works correctly in my Django server. ... If there is --cov in pytest.ini, then breakpoints in pycharm won't work, after ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › microsoft › debugpy › issues › 1289
Pytest debug breakpoints not hit using python 3.11 · Issue #1289 · microsoft/debugpy
May 11, 2023 - Type: Bug Behaviour Running a pytest in debug mode no longer stops at breakpoints when using Python 3.11 (works in Python3.10). Expected vs. Actual Pytest running in debug mode should stop on breakpoints. Instead it doesn't and the follo...
Published   May 11, 2023
Author   morybc
🌐
GitHub
github.com › microsoft › vscode-python › issues › 693
Debugger doesn't stop at breakpoints with pytest if ...
February 2, 2018 - If I remove the file (or at least the --cov), I get back my breakpoints stop. I changed my setup to put that in my Travis file instead, but I feel like this should work :/ I should be able to have this file (and coverage) and debug at the same time. ... area-debuggingarea-testingfeature-requestRequest for new features or functionalityRequest for new features or functionalityneeds PRReady to be worked onReady to be worked on
Author   lmazuel
🌐
SeleniumBase
seleniumbase.com › home › the ultimate pytest debugging guide
The ultimate pytest debugging guide - SeleniumBase
June 25, 2022 - When Debug Mode is activated, the ... see how variables look from the command-line. (Note that you may need to add "-s" to your "pytest" run command to allow breakpoints, unless you already have a "pytest.ini" file present with ...
Find elsewhere
🌐
Jarrousse
blog.jarrousse.org › home › howto › how to fix the issue: debugging pytest is not working with pycharm
How to fix the issue: Debugging pytest is not working with PyCharm -
July 14, 2024 - The best work-around that I found is to disable coverage when debugging, and here we can simply comment the –cov argument in the pytest.ini or even better to add the –no-cov argument to the PyCharm configuration, as shown in the following ...
🌐
O'Reilly
oreilly.com › library › view › python-testing-with › 9781680509427 › f_0150.xhtml
Debugging with pdb - Python Testing with pytest [Book]
February 18, 2022 - When a pytest run hits a breakpoint() function call, it will stop there and launch pdb. Use the --pdb flag. With --pdb, pytest will stop at the point of failure. In our case, that will be at the assert len(the_list) == 2 line. Use the --trace flag. With --trace, pytest will stop at the beginning of each test. For our purposes, combining --lf and --trace will work perfectly.
Author   Brian Okken
Published   2022
Pages   274
🌐
Better Stack
betterstack.com › community › questions › how-to-debug-pytest-with-pdb-breakpoints
How to Debug Pytest With pdb Breakpoints? | Better Stack Community
... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > /Users/stanley/test_exception.py(12)test_zero_division() -> with pytest.raises(ZeroDivisionError): (Pdb) Another way to set breakpoints is using the built-in breakpoint() function, which simplifies the process of setting breakpoints: ... This method is often preferred for its simplicity compared to import pdb; pdb.set_trace(). ... This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
🌐
pytest
docs.pytest.org › en › 6.2.x › usage.html
Usage and Invocations — pytest documentation
To set a breakpoint in your code use the native Python import pdb;pdb.set_trace() call in your code and pytest automatically disables its output capture for that test: Output capture in other tests is not affected.
🌐
Readthedocs
pytest-cov.readthedocs.io › en › latest › debuggers.html
Debuggers and PyCharm - pytest-cov 7.0.0 documentation
This manifests itself in behaviour that PyCharm might not hit a breakpoint no matter what the user does, or encountering an error like this: PYDEV DEBUGGER WARNING: sys.settrace() should not be used when the debugger is being used. This may cause the debugger to stop working correctly. Since it is common practice to have coverage configuration in the pytest.ini file and pytest does not support removeopts or similar the –no-cov flag can disable coverage completely.
🌐
JetBrains
jetbrains.com › guide › pytest › tutorials › visual_pytest › debugging_during_testing
Debugging During Testing - JetBrains Guide
June 26, 2024 - You could learn how to generate console output in pytest, but that would be the same issue -- writing debugging statements into your code which you might accidentally check in. The debugger was meant for this. Fortunately PyCharm has a great "visual" debugger, tightly integrated with "visual testing." Let's use that. Remove the print statement and instead, click in the gutter beside the first line in that test function. This adds a red circle to indicate a breakpoint at assert player_one.primary_guardian:
🌐
tutorialpedia
tutorialpedia.org › blog › unable-to-debug-in-pycharm-with-pytest
PyCharm pytest Debugging: Why Breakpoints Aren't Stopping (Troubleshooting Guide) — tutorialpedia.org
In the run config, check "Python interpreter" (under "Configuration" tab). If it’s incorrect, select the correct virtual environment (e.g., venv/bin/python or conda env). Sometimes the breakpoint itself is misconfigured or inactive.
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-20186
debugging of py.test does not stop on breakpoints if ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
Visual Studio Code
code.visualstudio.com › docs › python › testing
Python testing in Visual Studio Code
November 3, 2021 - rootdir is dynamically adjusted based on the presence of a python.testing.cwd setting in your workspace. You can also configure pytest using a pytest.ini file as described on pytest Configuration. ... If you have the pytest-cov coverage module installed, VS Code doesn't stop at breakpoints while debugging because pytest-cov is using the same technique to access the source code being run.
🌐
GitHub
github.com › microsoft › debugpy › issues › 1175
Debugging tests is not stopping on breakpoint · Issue #1175 · microsoft/debugpy
January 13, 2023 - Type: Bug Behaviour Expected vs. Actual Expected: setting a breakpoint on a test and then debugging the test should trigger the breakpoint to enable step-by-step execution of the test. Actual: the test just runs through. The debugger pan...
Author   pcolmer
🌐
Qxf2 BLOG
qxf2.com › home › debugging in python using pytest.set_trace()
Debugging in Python using pytest.set_trace() - Qxf2 BLOG
October 30, 2024 - Immediately when this line is executed, Python debugger starts a pdb prompt and waits for user instructions on the next steps in the interactive mode. Python 3.7 brings in a built-in function called breakpoint() which by default will import pdb and call pdb.set_trace()