Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow for setting up a debug configuration for tests #332

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

Closed
lmazuel opened this issue Dec 2, 2017 · 9 comments
Closed

Allow for setting up a debug configuration for tests #332

lmazuel opened this issue Dec 2, 2017 · 9 comments
Labels
area-debugging area-testing feature-request Request for new features or functionality

Comments

@lmazuel
Copy link
Member

lmazuel commented Dec 2, 2017

Environment data

VS Code version: 1.18.1
Python Extension version: 0.8.0
Python Version: 3.6
OS and version: Windows 10 falls update

Actual behavior

"Step into" when debugging does not let me go inside a lib installed in the venv (not the current personal code)

Expected behavior

"Step into" let me step into whatever code (mine or dependencies).

Steps to reproduce:

  • Place a breakpoint on a requests.get
  • Step into

Logs

N/A

PTVS has an option for that, and possible in PyDev (but full disclosure it was a long time ago for this one...)

@brettcannon brettcannon added awaiting 1-verification area-debugging bug Issue identified by VS Code Team member as probable bug labels Dec 2, 2017
@DonJayamanne
Copy link

@lmazuel this is possible today.
Please try the following and let me know how it goes.

  • Open your launch.json,
  • find the relevant launch configuration
  • add the entry DebugStdLib into the array debugOptions.

Please note, this is only an example, all you need to do is add DebugStdLib into the existing list:

"debugOptions": [
    "RedirectOutput","DebugStdLib"
],

Please let me know how this goes.

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster and removed awaiting 1-verification labels Dec 2, 2017
@lmazuel
Copy link
Member Author

lmazuel commented Dec 2, 2017

Hi the "Debug" button with pytest enabled":
image

So I don't have a launch.json. Have I?

@DonJayamanne
Copy link

DonJayamanne commented Dec 2, 2017

Aah, you're debugging a unit test. That's new information.
Currently we don't support debugging non-user code when debugging unit tests.
That would be a new feature.

@DonJayamanne DonJayamanne added awaiting 1-decision area-testing feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster bug Issue identified by VS Code Team member as probable bug labels Dec 2, 2017
@lmazuel
Copy link
Member Author

lmazuel commented Dec 2, 2017

Sorry, didn't realize it was relevant information :/

I tried using the "Python" launcher and it works! At least I have a workaround when needed in the meantime. Thanks!

@lmazuel lmazuel changed the title Step into a lib installed in the venv in debug mode Step into a lib installed in the venv while debugging a unittest Dec 2, 2017
@DonJayamanne
Copy link

Sorry, didn't realize it was relevant information :/

No worries, at least we got to the bottom of it very quickly. Would have been a another story if you hadn't sent the screen shots. lol.

Will keep you posted.

@brettcannon brettcannon changed the title Step into a lib installed in the venv while debugging a unittest Allow for setting up a debug configuration for tests Apr 10, 2018
@tzookb
Copy link

tzookb commented Oct 18, 2018

Hey @brettcannon

quite sometime since its closed
but still not sure if I can "debug" my unit tests?

Asked it on StackOverflow but no responses
so last option here :)

https://stackoverflow.com/questions/52867639/vscode-python-debug-with-unit-tests

Thanks!

@brettcannon
Copy link
Member

@tzookb this issue is actually still open so I'm not sure what you're referring to as "closed".

As for debugging a test, you can always click the "Debug Test" code lens for discovered tests. This issue is about setting up specific launch.json configurations for tests.

@qubitron
Copy link

qubitron commented Jan 31, 2019

Check launch.json for the existence of a debug configuration named "Python: Unit Tests", if it exists, use it, if not generate an in-memory one as we do today.

Document a sample launch.json for providing additional unit test settings, including: setting environment variables, enable debugStdLib.

See src/client/unittests/common/debugLauncher.ts.

@DonJayamanne
Copy link

Created a section in launch.json as follows:

        {
            "type": "python",
            "request": "test",
            "name": "wow",
            "env": {
                "HELLO": "HMM"
            }
        }

Got the following error in VSC:
could not load unit test config from launch.json

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging area-testing feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

7 participants