Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

justMyCode: false ignored in python 3.12 and above when running tests #24439

Open
falkben opened this issue Nov 13, 2024 · 12 comments
Open

justMyCode: false ignored in python 3.12 and above when running tests #24439

falkben opened this issue Nov 13, 2024 · 12 comments
Assignees
Labels
feature-request Request for new features or functionality triage-needed Needs assignment to the proper sub-team

Comments

@falkben
Copy link

falkben commented Nov 13, 2024

Note: I could not get the Issue Reporter to work in vscode, so I had to use the feature-request link to create this.

Behaviour

In Python 3.12 and above, when debugging tests, the "justMyCode": false setting is ignored.

Steps to reproduce:

  1. install pytest and an external library in a virtual environment using python 3.12 or 3.13 (in my example below I used requests)
  2. Create a file called test_external_library.py and create a simple function that calls the external library
  3. Create a simple test that calls your function
  4. Set a breakpoint in the external library
  5. create a launch.json config for debug-test that includes justMyCode set to false.
  6. Run the test using one of the interfaces in vscode.
  7. Observe that in python 3.12 or 3.13 the breakpoint is ignored. In python 3.11 (and previous), the debugger stops at the breakpoint inside the external library.

Note: this occurs with python installations using uv, conda and homebrew.

Example test_external_library.py:

import requests

def get_example():
    r = requests.get("https://example.com")
    return r.text


def test_get_example():
    assert "Example Domain" in get_example()

In this situation, I set a breakpoint inside the requests get function (inside api.py)

launch.json config:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Tests",
            "type": "debugpy",
            "request": "launch",
            "purpose": [
                "debug-test"
            ],
            "justMyCode": false,
            "console": "integratedTerminal"
        }
    ]
}

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-11-13 17:22:40.236 [warning] Dir "/Users/bfalk/repos/advent-of-code/.pixi/envs" is not watchable (directory does not exist)
2024-11-13 17:22:40.236 [info] Python interpreter path: ./.venv/bin/python
2024-11-13 17:22:40.249 [info] > pyenv which python
2024-11-13 17:22:40.249 [info] cwd: .
2024-11-13 17:22:41.360 [info] Starting Pylance language server.
2024-11-13 17:36:19.069 [info] Discover tests for workspace name: advent-of-code - uri: /Users/bfalk/repos/advent-of-code
2024-11-13 17:36:19.089 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py
2024-11-13 17:36:19.089 [info] shell: bash
2024-11-13 17:36:19.252 [info] > ./.venv/bin/python ~/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests
2024-11-13 17:36:19.252 [info] cwd: .
2024-11-13 17:36:26.597 [info] > ./.venv/bin/python -m pytest --rootdir . --override-ini junit_family=xunit1 --junit-xml=/var/folders/d5/7lllrg_s1238gsx2j2ng9bqw0002h3/T/tmp-34581rKova1P4u5CN.xml ./tests/test_requests.py::test_get_example
2024-11-13 17:36:26.597 [info] cwd: .
2024-11-13 17:36:31.841 [info] Using configuration in launch.json
2024-11-13 17:36:32.054 [info] CreateEnv Trigger - Skipping for /Users/bfalk/repos/advent-of-code
2024-11-13 17:36:32.157 [info] Send text to terminal: source /Users/bfalk/repos/advent-of-code/.venv/bin/activate
2024-11-13 17:36:32.706 [info] Send text to terminal:  /usr/bin/env /Users/bfalk/repos/advent-of-code/.venv/bin/python /Users/bfalk/.vscode/extensions/ms-python.debugpy-2024.13.2024111101-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher 49669 -- /Users/bfalk/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/testlauncher.py /Users/bfalk/repos/advent-of-code pytest --rootdir /Users/bfalk/repos/advent-of-code --override-ini junit_family=xunit1 --junit-xml=/var/folders/d5/7lllrg_s1238gsx2j2ng9bqw0002h3/T/tmp-34581xrpDKxB2YyK2.xml --capture no ./tests/test_requests.py::test_get_example 

@falkben falkben added the feature-request Request for new features or functionality label Nov 13, 2024
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 13, 2024
@eleanorjboyd
Copy link
Member

@justschen - tagging you since user reported issue with the issue reporter

@eleanorjboyd
Copy link
Member

I will investigate- thank you for the report!

@jacobeatsspam
Copy link

I'm finding that justMyCode: false is affecting run behavior. When I set it, the debugger runner is not sourcing my python environment correctly, opting to search for python at ~/.local/lib/python<version>.

@alexwilson1
Copy link

Same issue here with justMyCode: false being ignored in 3.12. Reverted to 3.11 to debug something and it worked.

@lukaszkadlubowski
Copy link

lukaszkadlubowski commented Dec 6, 2024

Same here.

In Windows + python3.11 justMyCode: false it is working fine.

However, it is ignored when debugging tests for configurations such as WSL+python3.12 or Windows+python3.12. For what it's worth, there is a difference in popup messages when trying to step into the python standard library code, as it is shown below (the first one is for justMyCode: false and the second one is for justMyCode: true), but the incorrect debugging behavior is the same:

Frame skipped from debugging during step-in

@EuleMitKeule
Copy link

Can confirm this happening in WSL with Python 3.12.

@Rubikoid
Copy link

Confirming problem with debugging tests on SSH-Remote to MacOS on python 3.12.

Debugging tests don't work and either magic config like

        {
            "name": "Python: Debug Tests",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "purpose": [
                "debug-test",
                "debug-in-terminal",
            ],
            "console": "integratedTerminal",
            "justMyCode": false
        },

for launch.json don't work.

@eleanorjboyd
Copy link
Member

@anthonykim1 is this included with the 3.12 work you are doing or is this separate?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 11, 2024
@anthonykim1
Copy link

@eleanorjboyd Did you mean Python3.13 REPL in terminal related work? Then no, I think they are separate

Copy link

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
@falkben
Copy link
Author

falkben commented Jan 16, 2025

Should this be marked as a feature request? Was this fixed? I don't think this should be closed yet

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Jan 16, 2025
@flying-sheep
Copy link

Can you please pin this issue so the bot doesn’t bury it?

@anthonykim1 anthonykim1 reopened this Feb 3, 2025
@anthonykim1 anthonykim1 removed the triage-needed Needs assignment to the proper sub-team label Feb 3, 2025
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 3, 2025
@anthonykim1 anthonykim1 removed their assignment Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

9 participants