3

I'm encountering a persistent issue with PyCharm when trying to debug a pytest unit test.

Running the project normally and attaching the debugger works fine. Debugging regular scripts behaves as expected. But when I debug a pytest unit test:

  • The debugger halts at the first breakpoint.
  • It shows "Collecting data..." instead of displaying variable values.
  • Clicking "Step Over" or "Continue" does nothing — the debugger appears frozen.

Environment:

  • PyCharm version: 2025.2.0.1
  • Python version: 3.12.11
  • OS: macOS
  • Venv Manager: uv
  • pytest version: 8.4.0

I've tried:

  • Restarting PyCharm and invalidating caches.
  • Simplifying __str__ and __repr__ methods in my code.
  • Enabling Gevent compatible mode in the debugger settings — no improvement.
  • Verified that --cov is not present in my pytest.ini.
  • Tried adding --no-cov to the Additional Arguments in the Run/Debug Configuration, but this caused an error:
    unrecognized arguments: --no-cov
    

Has anyone found a reliable fix for this issue? Is there a workaround to get PyCharm's debugger working properly with pytest?

1
  • Have you configured a run configuration to debug pytest? Does it work when running from the terminal with the venv activated? Since the debugger is stuck on test discovery you should replicate the discovery in a terminal before trying to run it with the debugger because you're aiming at the debugger running like it does from the terminal. Commented Aug 27 at 0:43

0

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.