Pycharm is not recognizing breakpoints in non-test files
Been using Pycharm to write a server.
I have some unittests using the 'unittest' library from Python.
I was just running the tests and everything was fine, I could set breakpoints anywhere in the code. Yesterday I started running the server through the debugger. I found that my breakpoints no longer worked. Visually they are still there, they look/behave in every way like a working break point, except they don't actually cause execution to break, they are just ignored (as if they were disabled).
Today when I tried to run tests again, I am observing the same开发者_JAVA百科 behavior in all files except those in my test library.
I tried an experiment, adding a new file to the server code with a simple function in it. Breakpoint in function, call function from test, run test through debugger, no break. Copied the file into my 'tests' directory, reset the breakpoint in the function, changed 'import' statement to point to new location of test file, ran tests. Now it stops at the breakpoint in the file.
I have tried every basic 'sanity check' I can think of: quit PyCharm. Re-install PyCharm. Delete PyCharm preferences. Reboot. I still get the exact same behavior.
For what it's worth, 'run to cursor' exhibits the same problem: in anything but test file, it just runs without stopping.
What is really crazy-making is this was all working fine yesterday. At least breakpoints were working when I was running tests.
Kinda sorta fixed this myself.
In Run->Edit Configurations, selected the config for testing.
In "Tests:Folder:", the existing setting was foo/bar/baz/my_project/tests.
With this setting I had the problem: breakpoints under 'tests' work, breakpoints under the rest of 'my_project' don't.
I changed it to foo/bar/baz/my_project. Now it all works as expected, breakpoints anywhere work fine.
Other people on my project have things working fine with the original setting: they are pointing just to the 'tests' directory and can set breakpoints anywhere.
I am not sure why I am special and this fails for me, but I have a workaround and I'm tired of fighting with it so.... good times.
Hey Doug, three things that may or may not be helpful:
- I've had the same issue a couple of times back with the earlier 1.0 and 1.0.1 releases with saved debug configurations --- recreating the debug configuration fixed the glitch. Knock on wood, but I haven't had the issue in 1.1.1. Have not tried the 1.2 release candidate.
- A colleague had a similar issue, but he accidentally set his breakpoints on an external copy of the file, not what PyCharm was executing.
- Lastly my experience is that the JetBrains folks have been pretty good about responding to issues if you ping their user forum and/or submit a YouTrack bug.
Cheers, Rob
精彩评论