Repository navigation
JustMyCode doesn't work when debugging python tests through the GUI #21249
Description
Type: Bug
Behaviour
Expected vs. Actual
I cannot disable "just my code" and debug tests through the GUI.
Also, [object Object] notification keeps popping
Steps to reproduce:
When I setup the "Python: Debug Tests" configuration in my code workspace (launch section) as stated in the documentation, then click on "Testing" tab, then "Debug test", the debugger always skips thirdparty code.
https://code.visualstudio.com/docs/python/testing#_debug-tests
The same happens with "Test: Debug Test at Cursor" command.
I would like "justMyCode" to be interpreted.
Note: I have uninstalled pytest-cov and coverage and I still have the problem.
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServersetting: Default
pytest==6.2.4
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2023-05-15 10:40:02.562 [info] Telemetry is disabled
2023-05-15 10:40:02.562 [info] Experiments are disabled, only manually opted experiments are active.
2023-05-15 10:40:02.562 [info] Test server listening.
2023-05-15 10:40:02.562 [info] Python interpreter path: ./.venv/bin/python
2023-05-15 10:40:03.301 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS
2023-05-15 10:40:03.402 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS
2023-05-15 10:40:03.402 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS
2023-05-15 10:40:03.402 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS
2023-05-15 10:40:03.402 [warning] Retry failed, storage update failed for key PYTHON_GLOBAL_STORAGE_KEYS
2023-05-15 10:40:03.403 [info] Send text to terminal: source /home/dev/projects/myproject/.venv/bin/activate
2023-05-15 10:40:04.268 [info] Starting Pylance language server.
2023-05-15 10:40:06.684 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-server/extensions/ms-python.python-2023.8.0/pythonFiles/printEnvVariables.py
2023-05-15 10:40:06.684 [info] shell: bash
2023-05-15 10:40:06.738 [info] > ./.venv/bin/python ~/.vscode-server/extensions/ms-python.python-2023.8.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
2023-05-15 10:40:06.738 [info] cwd: .
User Settings
languageServer: "Pylance"
testing
• pytestEnabled: true
============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-6.2.4, py-1.11.0, pluggy-0.13.1
rootdir: /home/dev/projects/test
plugins: html-3.1.1, metadata-2.0.1
collected 1 item
......
Frame skipped from debugging during step-in.
Note: may have been skipped because of "justMyCode" option (default == true). Try setting "justMyCode": false in the debug configuration (e.g., launch.json).
Extension version: 2023.8.0
VS Code version: Code 1.78.1 (6a995c4f4cc2ced6e3237749973982e751cb0bf9, 2023-05-04T09:48:08.683Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Sandboxed: No
Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz (16 x 2904) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | undefined |
| Memory (System) | 31.72GB (12.32GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | WSL: Ubuntu-20.04 |
| OS | Linux x64 5.15.90.1-microsoft-standard-WSL2 |
| CPUs | Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz (16 x 2904) |
| Memory (System) | 9.72GB (6.40GB free) |
| VM | 0% |


Activity
[-]JustMyCode doesn't work in python tests[/-][+]JustMyCode doesn't work when debugging python tests through the GUI[/+]paulacamargo25 commentedon May 15, 2023
Hi NicolasM-Forsk, can you send me your launch.json config? Thanks
nmoreaud commentedon May 16, 2023
test.code-workspace:
{ "folders": [ { "path": "/home/dev/projects/test" } ], "settings": { "python.testing.pytestEnabled": true }, "launch": { "configurations": [ { "name": "Python: Debug Tests", "type": "python", "request": "launch", "program": "${file}", "purpose": ["debug-test"], "console": "integratedTerminal", "justMyCode": false } ] } }nmoreaud commentedon May 19, 2023
Here is a simple example project to reproduce the "bug": sample.zip
The goal here is to be able to step in
json.dumpsSetup:
paulacamargo25 commentedon Jun 2, 2023
Thanks nmoreaud for the reply, I was able to reproduce the issue, what happens is that we are only reading the config from the launch.json file fro tests.
We will be fixing it in the next iteration, what you can do in the meantime is put that same configuration in the launch.json file and it will work.
Thank you
4 remaining items
nmoreaud commentedon Jun 5, 2023
Ok, I opened this other issue: #21365
21249 read launch config in workspace file (#21426)
paulacamargo25 commentedon Jun 27, 2023
Verification steps:
{ "folders": [ { "path": "/home/dev/projects/test" } ], "settings": { "python.testing.pytestEnabled": true }, "launch": { "configurations": [ { "name": "Python: Debug Tests", "type": "python", "request": "launch", "program": "${file}", "purpose": ["debug-test"], "console": "integratedTerminal", "justMyCode": true } ] } }andreamah commentedon Jun 28, 2023
Hi Paula (@paulacamargo25)! For verification, could you provide some test file content that I could test with? Also, how would I know that justMyCode is used?
paulacamargo25 commentedon Jun 28, 2023
Sure, you can try with test-issue-21249.zip.
justMyCodeallows you to specify if you want to debug only your code (justMyCode=true) or if you want to also debug the code of the libraries you use (justMyCode=false). By defaull is true.pip install pytest.justMyCode=false.assert json.dumps({'toto': 'tata'}) == "{'toto': 'tata'}".