Pytest discovery broken when discovery python process adds stuff to output

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

> ./.venv/bin/python ~/.cursor-server/extensions/ms-python.python-2023.6.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear .
cwd: .
[ERROR 2025-9-30 11:27:18.529]: Error discovering pytest tests:
...
tests/utils/test_string.py:15", "markers": [], "parentid": "./src/flows/tests/utils/test_string.py"}]}]
Error: Not freed memory blocks: 26430, total unfreed memory 8.260136 MB

	at JSON.parse (<anonymous>)
	at s.runTestDiscovery (/home/kokottc/.cursor-server/extensions/ms-python.python-2023.6.0/out/client/extension.js:2:797673)
	at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
	at async Promise.all (index 0)
	at async _.refreshTestData (/home/kokottc/.cursor-server/extensions/ms-python.python-2023.6.0/out/client/extension.js:2:827403)
	at async I.refreshTestDataInternal (/home/kokottc/.cursor-server/extensions/ms-python.python-2023.6.0/out/client/extension.js:2:814398)]

The problem is that a dependency, bpy, adds this “Error: Not freed memory blocks” to the output, which then is being parsed as json and failing.

Something changed here right? It used to use pure pytest discovery instead of this adapter script right?

This bug is documented in the vscode-python but marked as closed: Support an output stream from the testing adapter script. · Issue #6594 · microsoft/vscode-python · GitHub

Steps to Reproduce

Have python files in your tests that create extra output.
Run python test discovery via IDE

Expected Behavior

The tests should be discovered and discovery should not fail if any unexpected output is placed by discovery process.

Operating System

Linux

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.0.38 (Universal)
VSCode Version: 1.99.3
Commit: 3fa438a81d579067162dd8767025b788454e6f90
Date: 2025-10-29T20:45:40.883Z (14 hrs ago)
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Darwin arm64 25.0.0

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Thanks for the detailed bug report!

I notice you’re using an older version of the Python extension (2023.6.0). Could you try:

  1. Update the Python extension: Open Extensions (Cmd/Ctrl+Shift+X) → search for “Python” → update to the latest version. This may have fixes for the test discovery adapter.

Let me know if updating the extension resolves it!

Oh you are right! I did not notice because my cursor logged into a fresh ssh session did not offer me this upgrade.

When opening cursor on my local machine I had the latest version. But whenever logging via remote ssh into another machine it was using this old one. I had to specifically go to “Extensions: Install specific version of extension…” to upgrade the package.

Thats probably a bug!

But my original issue has been fixed, thank you!