None of the solutions mentioned here or elsewhere worked for me.
I have multiple copies of the same project in different folders. Some copies were fine, others exhibited the following behavior:
debugger would ignore any breakpoints in tests (regardless if these were run as single functions, classes, modules, batches)
breakpoints set in actual code called by these tests were hit
What did work for me (4 broken repos and counting):
Delete contents of __pycache__
folders in your project, starting out from the directory where your undebuggable test module is located. Remove the .pyc
file with the name of the undebuggable module first. If this doesn't help, identify any own imports used in the test, locate and delete the __pycache__
/.pyc
for them as well.
(Note: use a file browsing tool like File Explorer because Pycharm doesn't show these directories in the project view.)
If you're still out of luck or just plain lazy (like me), wipe all the __pycache__
folders you have in your repo. You can do this via your command line/terminal, just navigate yourself to the repo folder and then:
EDIT:
Made the description a bit detailed after recent findings, added a quick wipe hint. Noticed afterwards that @mcsj120 already suggested this in Antonin's post, so kudos to him!