Python unittest debug seems broken
See original GitHub issueIssue Type: Bug
I am new to Python unittest, but I think this should work:
"""Unit tests for some module."""
import unittest
class TestSomething(unittest.TestCase):
"""Test with strings for now."""
def test_MyThing(self):
"""Test thing and succeed."""
self.assertEqual(1, 1)
def test_Thing2(self):
"""Test thing and succeed."""
self.assertEqual(1, 1)
if __name__ == '__main__':
unittest.main()`
On running ‘Discover Unit Tests’, this file (test_something.py) is found and shows in the Test sidebar. On opening the file The CodeLens decorators appear. The various ‘Run Test’ commands work and the tests are shown as succeeding (I mention all this because there was lots of backtracking and trying various solutions found in GitHub issues around testing, including wiping and reinstalling the ms-python extension, to get to these parts working reliably).
When I attempt to ‘Debug Test’, a message “Could not load unit test config from launch.json” appears in the lower right and the spinners (Running Tests in bottom bar and by the test method in sidebar) are spinning. On closing the message, I drop into the debugger looking at visualstudio_py_testlauncher.py.
My reading of GitHub issues is that I should not need an entry in launch.json. Trying Add Configuration -> Python: Unit Tests adds an entry, but seems to make no difference.
From the debugger I can stop the debugger and return to the test file in a state with the spinners stopped and still able to successfully run the tests. There is another mode (perhaps the message display times out and I have not closed it to enter the debugger?) where the spinners continue, but I can stop them by editing/saving the file - but now when I Run Tests, the spinners just start again with no result. Presumably the other process is still running somewhere and I don’t see it, but it is very unintuitive at this point.
Extension version: 2019.2.5558 VS Code version: Code 1.32.3 (a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4, 2019-03-14T22:46:48.547Z) OS version: Darwin x64 18.2.0
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i5-6500 CPU @ 3.20GHz (4 x 3200) |
GPU Status | 2d_canvas: enabled checker_imaging: disabled_off flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on native_gpu_memory_buffers: enabled rasterization: unavailable_off surface_synchronization: enabled_on video_decode: enabled webgl: enabled webgl2: enabled |
Load (avg) | 3, 3, 3 |
Memory (System) | 32.00GB (13.67GB free) |
Process Argv | |
Screen Reader | no |
VM | 0% |
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top GitHub Comments
Thanks, replacing launch.json did solve the problem of the error message, and thus control is reliably returned after ‘Debug Test’ is run.
Good to know! AFAIK We are currently working on the second point you mentioned. You can open up an issue for any improvements you can think of.