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

SystemExit while debugging unit test method #3201

Closed
pniedzwiedzinski opened this issue Nov 5, 2018 · 14 comments
Closed

SystemExit while debugging unit test method #3201

pniedzwiedzinski opened this issue Nov 5, 2018 · 14 comments
Assignees
Labels
area-debugging area-testing bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority

Comments

@pniedzwiedzinski
Copy link

Environment data

  • VS Code version: 1.28.2
  • Extension version (available under the Extensions sidebar): 2018.9.2
  • OS and version: macOS Mojave 10.14
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: pytest 3.6.0

Actual behavior

When I run Debug unit test method... and choosing the test to debug it opens testlauncher.py and shows this message:

Exception has occurred: SystemExit
0
  File "~/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/testlauncher.py", line 58, in run
    pass
  File "~/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/testlauncher.py", line 64, in <module>
    run(cwd, testRunner, args)

Expected behavior

Start debugging 😄

Steps to reproduce:

  1. Open command palette
  2. Run Python: Debug unit test method...
  3. Choose a method to run

Logs

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

Starting Microsoft Python language server.
##########Linting Output - pylint##########
************* Module testlauncher
23,8,error,E0611:No name 'debugger' in module 'ptvsd'
23,8,error,E0401:Unable to import 'ptvsd.debugger'
26,8,error,E1101:Class 'traceback' has no 'print_exc' member
26,8,error,E0602:Undefined variable 'traceback'
22,8,warning,W0612:Unused variable 'ptvsd'
54,12,error,E0401:Unable to import 'nose'

------------------------------------------------------------------
Your code has been rated at 1.88/10 (previous run: 1.88/10, +0.00)

Microsoft Python Language Server version 0.1.50.0
Initializing for ~/path/to/project/venv/bin/python
##########Linting Output - pylint##########

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

##########Linting Output - pylint##########
************* Module testlauncher
23,8,error,E0611:No name 'debugger' in module 'ptvsd'
23,8,error,E0401:Unable to import 'ptvsd.debugger'
26,8,error,E1101:Class 'traceback' has no 'print_exc' member
26,8,error,E0602:Undefined variable 'traceback'
22,8,warning,W0612:Unused variable 'ptvsd'
54,12,error,E0401:Unable to import 'nose'

------------------------------------------------------------------
Your code has been rated at 1.88/10 (previous run: 1.88/10, +0.00)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

No output
@brettcannon brettcannon self-assigned this Nov 6, 2018
@brettcannon
Copy link
Member

Did you have ~/.vscode/extensions/ms-python.python-2018.9.2/pythonFiles/experimental/testlauncher.py open to get those linting errors?

@pniedzwiedzinski
Copy link
Author

No, it opens as I am starting debuging

@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug needs PR area-debugging and removed triage labels Nov 8, 2018
@brettcannon brettcannon removed their assignment Nov 8, 2018
@brettcannon brettcannon added important Issue identified as high-priority and removed P0 labels Nov 8, 2018
@DonJayamanne
Copy link

DonJayamanne commented Nov 8, 2018

Upstream issue: microsoft/ptvsd#1268 (was microsoft/ptvsd#997).

@piotr-kubica
Copy link

I'm experiencing exactly same issue as butterfly-pn

@syagev
Copy link

syagev commented Jan 6, 2019

This is happening because the test itself is raising an exception right? (at least that's what I'm experiencing running a pytest module, which is raising an uncaught exception during execution).

Once this is fixed, will the debugger stop at the right place on "uncaught exceptions" within test code?

@brettcannon
Copy link
Member

@syagev there's a deeper layer usage of SystemExit that is triggering this. But once this is fixed it shouldn't affect other tests.

@madig
Copy link

madig commented Feb 14, 2019

I have an "issue" in that debugging a test that completes successfully opens the Python extension's testlauncher.py with a SystemExit exception, which I find somewhere between distracting and annoying. Is that related or a different issue?

@brettcannon
Copy link
Member

@madig same issue and it should be fixed in ptvsd master, so hopefully this will be resolved in the next release.

@DonJayamanne
Copy link

Prescribed solution:

  • Modify getLaunchArgs in debugLauncher.ts
    Add the files property to debugOptions to exclude all of the python code in our extension, i.e. exclude the pythonFiles folder.
        debugConfig.rules = [
            { path: '<fully qualified path>pythonFiles', include: false }
        ];

See here for contract details microsoft/ptvsd#997 (comment)

https://github.com/Microsoft/vscode-python/blob/master/src/client/unittests/common/debugLauncher.ts#L67-L75

@ericsnowcurrently
Copy link
Member

FYI, the fix was merged into PTVSD yesterday morning. @karthiknadig, we're good to go, right?

@karthiknadig
Copy link
Member

Yes. The fix is in master.

@ericsnowcurrently
Copy link
Member

@DonJayamanne, shouldn't we also remove all references to DONT_DEBUG in the various debug adapter scripts?

@DonJayamanne
Copy link

shouldn't we also remove all references to DONT_DEBUG in the various debug adapter scripts?

Yes agreed.

@karrtikr
Copy link

karrtikr commented Apr 8, 2019

Validated

@karrtikr karrtikr closed this as completed Apr 8, 2019
@ghost ghost removed needs PR labels Apr 8, 2019
rukmal added a commit to rukmal/precis that referenced this issue Apr 13, 2019
…ecause the vscode-python extension is currently broken w.r.t. this. See microsoft/vscode-python#3201 for more; waiting for the next version of the extension to ship until I can use it again
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging area-testing bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority
Projects
None yet
Development

No branches or pull requests

10 participants