[Python] PyCharm Debugger Stuck on "Collecting data..." When Debugging Pytest Unit Test

Discussão em 'Python' iniciado por Stack, Agosto 18, 2025.

  1. Stack

    Stack Membro Participativo

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

    What works:

    • Running the project normally and attaching the debugger works fine.
    • Debugging regular scripts behaves as expected.
    What doesn't work:

    • 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
    What 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
    Question:


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

    Any help would be greatly appreciated!

    Continue reading...

Compartilhe esta Página