Pycharm version: 2020.3.3
OS: macOS Big Sur (11.1)
I am experiencing inconsistent breakpoint behavior when using a docker image as the Python interpreter and debugging unit tests. I suspect it is specific to the use of the remote debug server under the hood in this configuration - I do *not* experience this when debugging against a python environment native to the host.
After going through some of the similar existing posts and trying various workarounds to no avail, I eventually made a remarkable discovery by experimentation that I hope will be specific enough to facilitate tracking down the root cause (and which also provides me a de facto workaround, albeit an unsatisfying one). My experiment goes like this
- I open up a test file in my project that I haven't visited before
- Set a breakpoint in a test
- Click "debug". for the test
- The test runs to completion without hitting the debugger - I can repeat, set more breakpoints on other lines, etc but none will stop
- Touch the test file in the filesystem, i.e. `touch tests/foobar.py` from a separate console window
- Click debug again
- Now all breakpoints in the file are respected!
I'd tried invalidating the cache, recreating my project, restarting PyCharm, but the state is preserved across all of these (in the sense that a once-touched file continues to respect breakpoints). So I suspect it is really just a question of the timestamp on the file. For additional confirmation I tried another experiment - setting the file's timestamp back to what it was before, i.e. ` touch -m -a -t "202102090925" tests/foobar.py`, which causes the breakpoint to stop working again.
Hoping that analysis is informative enough to find a proper explanation and save someone else from the confusion I just went through!