Skip to content

Error message when debugging Python tests is unhelpful #17150

Closed

Description

'This configuration can only be used by the test debugging commands. `"request": "test"` is deprecated use "purpose" instead.',

The official documentation for debugging Python tests (https://code.visualstudio.com/docs/python/testing#_debug-tests) states: "To customize settings for debugging tests, you can specify "request":"test" in the launch.json file." However, when I configure my launch.json file like that, and then try to run w/ debug (F5), I get an error message: "This configuration can only be used by the test debugging commands. '"request": "test"' is deprecated use "purpose" instead."

I don't mind changing my launch.json file. However, in order to comply with the error message and "use 'purpose' instead," I need to know the precise syntax to use. The phrase "use purpose" doesn't tell me if that should be the key or the value in the json - should it be "purpose": "test" or should it be "request": "purpose"? Actually, neither one of these work. Both throw an error. Either "Attribute 'request' has an unsupported value 'purpose' in the chosen debug configuration", or "This configuration can only be used as defined by purpose."

As a user who is trying to just be able to debug tests in Python, I am left scratching my head.

If it is helpful, here is my launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Run Current File (External Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        },
        {
            "name": "Python: Debug Tests (Integrated Terminal)",
            "type": "python",
            "request": "test",
            //"request": "purpose",
            //"purpose": "test",
            "console": "integratedTerminal",
            "justMyCode": false,
            "stopOnEntry": false
        }
    ]
}

Activity

  1. added
    triage-needed
    on Aug 29, 2021
  2. karthiknadig commented on Aug 30, 2021

    @karthiknadig
    Member

    Jeff Wright (@jeffwright13) Which version of the extension are you using? If it is insiders version (2021.9.*-dev) then this should work:

                "name": "Python: Debug Tests (Integrated Terminal)",
                "type": "python",
                "request": "launch",
                "purpose": ["debug-test"],  // <---- this 
                "console": "integratedTerminal",
                "justMyCode": false,
                "stopOnEntry": false
    

    If you are using insiders you should see this:
    image

  3. jeffwright13 commented on Aug 30, 2021

    @jeffwright13
    Author

    Karthik Nadig (@karthiknadig) - I am running version v2021.9.1176299738-dev. I have since turned off all insiders options, but it appears as if the dev version has persisted (I did not specifically downgrade). However, I am now unable to get the original error message to appear.

    Is this new syntax ("purpose": ["debug-test"]) documented somewhere? That was the big issue for me...the error message told me I had something misconfigured but did not let me know what the valid options are, or point me to some documentation where the new options are listed.

  4. added
    area-editor-*
    bug
    and removed
    triage-needed
    on Aug 30, 2021
  5. jaron-l commented on Aug 30, 2021

    @jaron-l

    It looks like it's documented in their pull request for the 2021.9 release. I'm just commenting because I came here for the same reason and found the above link in my research. Doesn't seem like it works in the most recent non-dev release (at least in 2021.8.1159...) as tested on my computer.

    Edit: In the last sentence, I meant to say that the new method doesn't work and I confirmed it's not supposed to. The old, documented method does work on my computer.

  6. karthiknadig commented on Aug 30, 2021

    @karthiknadig
    Member

    Jeff Wright (@jeffwright13) We will update the documentation when we release 2021.09. We are planning on releasing it on Sep 1st 2021, see here for release date and details: #16930

  7. locked as resolved and limited conversation to collaborators on Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-editor-*bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions