Skip to content

JustMyCode doesn't work when debugging python tests through the GUI #21249

Closed

Description

@NicolasM-Forsk

Type: Bug

Behaviour

Expected vs. Actual

I cannot disable "just my code" and debug tests through the GUI.
Also, [object Object] notification keeps popping

image
image

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.languageServer setting: 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

  1. changed the title [-]JustMyCode doesn't work in python tests[/-] [+]JustMyCode doesn't work when debugging python tests through the GUI[/+] on May 15, 2023
  2. paulacamargo25 commented on May 15, 2023

    @paulacamargo25

    Hi NicolasM-Forsk, can you send me your launch.json config? Thanks

  3. nmoreaud commented on May 16, 2023

    @nmoreaud

    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
                }
            ]
        }
    }
  4. nmoreaud commented on May 19, 2023

    @nmoreaud

    Here is a simple example project to reproduce the "bug": sample.zip
    The goal here is to be able to step in json.dumps
    Setup:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install pytest
  5. paulacamargo25 commented on Jun 2, 2023

    @paulacamargo25

    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

  6. 4 remaining items

  7. nmoreaud commented on Jun 5, 2023

    @nmoreaud

    Ok, I opened this other issue: #21365

  8. paulacamargo25 commented on Jun 27, 2023

    @paulacamargo25

    Verification steps:

    • Setup the "Python: Debug Tests" configuration in the code workspace. with the value:
    {
        "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
                }
            ]
        }
    }
    • Run the tests, and make sure that the value in justMyCode is used.
  9. andreamah commented on Jun 28, 2023

    @andreamah

    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?

  10. paulacamargo25 commented on Jun 28, 2023

    @paulacamargo25

    Sure, you can try with test-issue-21249.zip. justMyCode allows 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.

    1. Create a venv.
    2. pip install pytest.
    3. Check that the value of justMyCode=false.
    4. Run the test with a breakpoint in assert json.dumps({'toto': 'tata'}) == "{'toto': 'tata'}".
    5. Check that the step in json.dumps works, and open the code for it.
  11. locked as resolved and limited conversation to collaborators on Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions