microsoft/vscode-python

Unit Test discovery crashes when "undefined" and can no longer run

DonJayamanne opened this issue · 8 comments

From @mcesnik on June 27, 2017 17:10

Environment data

VS Code version: 1.13.1
Python Extension version: 0.6.5
Python Version: 2.7.11
OS and version: Windows 10 + Mac OSX 11

Actual behavior

When saving code, unit test discovery occasionally hangs on an error "undefined" and cannot recover without restarting VS code. This does not happen but happens frequently enough to warrant a bug report.

Expected behavior

Discovery should not fail or should recover when the error happens.

Steps to reproduce:

  • Create a shortcut to run unit tests
  • Code a unit test, hit save
  • Before discovery completes try to run unit tests and see output console window shows "undefined"
  • Running unit tests again or discovery will no longer work
  • Restart IDE and start over.

Settings

Your launch.json (if dealing with debugger issues):
{
"version": "0.2.0",
"configurations": [

    {
        "name": "Python",
        "type": "python",
        "request": "launch",
        "stopOnEntry": true,
        "pythonPath": "$python.pythonPath}",
        "program": "${file}",
        "cwd": "${workspaceRoot}",
        "env": {},
        "envFile": "${workspaceRoot}/.env",
        "debugOptions": [
            "WaitOnAbnormalExit",
            "WaitOnNormalExit",
            "RedirectOutput"
        ]
    }
]

}

Your settings.json:
{
"files.exclude": {
"/*.pyc": true,
"
/pycache": true
},

"python.unitTest.unittestArgs": [
    "-v",
    "-f",
    "-s",
    "tests",
    "-p",
    "test_collector.py"
],
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.maxNumberOfProblems": 50,
"python.linting.pylintArgs": ["--rcfile=./.vscode/pylint.rc"],
"python.unitTest.unittestEnabled": true,
"python.formatting.formatOnSave": true

}

Logs

Output from Python output panel

Output from Console window (Help->Developer Tools menu)

Copied from original issue: DonJayamanne/pythonVSCode#1054

Please re-create the launch.json file and try again.

From @mcesnik on June 29, 2017 18:47

@DonJayamanne, sorry, is that done using the "Add Configuration" button in VS code? If so, cool, did that and will see how it goes.

From @mcesnik on June 30, 2017 17:45

This didn't seem to have any affect. I still get unit tests hanging when I save and try to run them too quickly.

Please could you provide a sample project that I could use to replicate this issue (or a repo), please do provide the instructions and necessary settings.json and launch.json files.

From @mcesnik on July 4, 2017 14:21

You can try this zip file: https://drive.google.com/open?id=0B49rqCI3E_Z2c2NnSXB1czdsTTQ

It's my first py project so go easy on me :) The .vscode folder has both settings.json and launch.json.

The steps to recreate don't always recreate the issue. I find if you edit a file hit save and run unit tests quickly enough the error happens (although I don't see any info anywhere after that). Once the error happens unit tests will "run" but never actually execute. I have to restart VS code.

@mcesnik , apologies for the delay, will look into this soon.

@mcesnik I believe this has been fixed. Please could you test this out on the latest version of the Python extension.

Feel free to reopen if this issue is still a problem.