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
--covis not present in mypytest.ini. - Tried adding
--no-covto 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?