Skip to content

Debugging unit tests hangs indefinitely #1009

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
veuncent opened this issue Mar 9, 2018 · 12 comments · Fixed by #1140
Closed

Debugging unit tests hangs indefinitely #1009

veuncent opened this issue Mar 9, 2018 · 12 comments · Fixed by #1140
Labels
area-testing bug Issue identified by VS Code Team member as probable bug

Comments

@veuncent
Copy link

veuncent commented Mar 9, 2018

Environment data

  • VS Code version: 1.21.0 x64
  • Extension version (available under the Extensions sidebar): Python 2018.2.1
  • OS and version: Windows 10
  • Python version: 2.7.14

Actual behavior

When clicking Debug Test nothing happens, except showing the Running Tests throbber at the bottom of the window indefinitely.

image

Expected behavior

Debugging line-by-line using breakpoints.

Steps to reproduce:

  1. I set up a minimal repo to reproduce this: https://github.com/veuncent/vsc-debug-test
  2. Open the folder in VSC
  3. Open the test.py file
  4. Click Debug Test above the testSomeService function

Logs

Output of Python Test Log at startup of VSC: Output 1.txt

No output is given when using the Debug Test text button above the testSomeFunction function.

Output after running a unit test using the Run Test button above the testSomeFunction function:

----------------------------------------------------------------------
Ran 1 test in 0.019s

OK
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug needs verification area-testing labels Mar 9, 2018
@DonJayamanne
Copy link

You haven't configured the unit tests in VS Code (see here https://code.visualstudio.com/docs/python/unit-testing)

Another way to do this is

  • Delete your settings.json file
  • Go into your command palette Python: Run All Unit Tests
  • Follow the prompts (select nose and select . as the directory containing the tests`

I've tested your repo at my end and it works.

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster and removed needs verification labels Mar 9, 2018
@veuncent
Copy link
Author

veuncent commented Mar 10, 2018

I did exactly as you asked and the problem is still there, unfortunately.
Is there any other information I can give you?

By the way: my Python VSC extension was updated yesterday to 2018.2.1, but nothing changed regarding this bug.

@DonJayamanne
Copy link

Please could you send your launch.json so I could have a look at that.

@veuncent
Copy link
Author

I use the launch.json in the git repo:
https://github.com/veuncent/vsc-debug-test/blob/master/.vscode/launch.json

That's the default one created by vsc

@DonJayamanne
Copy link

DonJayamanne commented Mar 11, 2018

You might want to check the docs https://code.visualstudio.com/docs/python/unit-testing

First, go into the command palette and select Run All Unittests, configure the test framework and use the code lense to debug a test or check it the documentation.

You cannot debug unit tests via debug configuration in launch.json unless you configure everything manually (the code lenses make it much simpler).

Between line 5 & 6 you'll find the code lense Debug Test, click on that (look at the screenshot you have attached).

@veuncent
Copy link
Author

veuncent commented Mar 12, 2018

I did exactly that what you describe :) And I do not debug via the debug configuration in launch.json.
Here is what I did:

  • From the command palette I ran Run all Unittests
  • I clicked Enable and configure a Test Framework (see screenshot)
  • Selected Nose from the dropdown menu
  • Selected . Root directory from the dropdown menu

image

This results in the creation of this settings,json:

{
    "python.unitTest.nosetestArgs": [
        "."
    ],
    "python.unitTest.nosetestsEnabled": true
}

(I just pushed that settings file to the repo here)

Subsequently the unit tests are discovered and the Code Lens buttons (Run Test | Debug Test) appear above my class and method.

When I click any of the Run Test code lens buttons the test runs fine and Python Test Log gives expected output (Ran 2 tests in 0.003s).

However, when I click any of the Debug Test code lens buttons, nothing happens, except for the Running Tests text appearing in the bottom of the screen:
image

@veuncent
Copy link
Author

P.s. I also tried:

  • Reinstalling VSC including the Python extension
  • Setting up from scratch, choosing unittest instead of nose

To no avail.

@brettcannon brettcannon added needs verification and removed info-needed Issue requires more information from poster labels Mar 12, 2018
@jitbasemartin
Copy link

Same issue here, but I use py.test
Windows 10 64bit, Python 2.7.14, pytest-3.4.2, py-1.5.2, pluggy-0.6.0

@DonJayamanne
Copy link

@veuncent @moimart1
Please could you install the latest development version of the extension from here and test this out once again.

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster and removed needs verification labels Mar 20, 2018
@jitbasemartin
Copy link

Yeah it works for me with pytest :)
Thanks @DonJayamanne !

@veuncent
Copy link
Author

veuncent commented Mar 21, 2018 via email

@DonJayamanne DonJayamanne added closed-verified fixed and removed info-needed Issue requires more information from poster labels Mar 21, 2018
@DonJayamanne
Copy link

Reopening to create news entry

@DonJayamanne DonJayamanne reopened this Mar 21, 2018
DonJayamanne added a commit that referenced this issue Mar 21, 2018
* 📝 add news entry
* 🔨 rephrase news entry
* Fixes #1009
@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants