vscode-python: unittest "unhandled exception in thread" after running tests

From @dosentmatter on January 26, 2017 19:30

Environment data

VS Code version: 1.8.1 Python Extension version: 0.5.6 Python Version: 3.5.2 and 3.6.0 OS and version: macOS Sierra Version 10.12.3

Actual behavior

I am using the standard unit testing framework, unittest. After running my tests, whether they pass or not and whether I run a single test or multiple tests, I get “Unhandled exception in thread started by” after the OK or FAILED. There is nothing after the “by” it is started “by<blank>”. It does not seem like a big problem though since tests are still run.

Expected behavior

I should not get the “Unhandled exception in thread started by” message.

Steps to reproduce:

  • Create a project folder
  • Create a file called test_unit.py and put this in it:
import unittest

class TestUnit(unittest.TestCase):

    def test_unit(self):
        pass
  • run all or the single unittest with the settings.json below.
  • Test passes with OK but you get “Unhandled exception in thread started by”.

Settings

Your launch.json (if dealing with debugger issues):
none Your settings.json:

// Place your settings in this file to overwrite default and user settings.
{
    "python.unitTest.unittestEnabled": true,

    "python.unitTest.unittestArgs": [
        "-v",
        "-p",
        "test_unit*.py"
    ]
}

Logs

Output from Python output panel

test_unit (test_unit.TestUnit) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.001s

OK
Unhandled exception in thread started by 

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

Copied from original issue: DonJayamanne/pythonVSCode#674

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (3 by maintainers)

Most upvoted comments

I’ve labeled this as a macOS issue since I can’t reproduce on Windows.

For my case of “Unhandled exception in thread started by” - seems to be happening when running in VSCode only for me?

test_sample.py:

import unittest
class SampleTestCase(unittest.TestCase):
    def setUp(self):
        print('TODO')
    def test_sync(self):
        print('TODO')

.vscode/settings.json:

{
    "python.unitTest.unittestArgs": [
        "-v",
        "-s",
        ".",
        "-p",
        "test_*.py"
    ],
    "python.unitTest.unittestEnabled": true
}

I get that error when running tests from VSCode but not when running this in commandline: python3 -m unittest discover -v -s . -p test_*.py

Same problem on Mac OS X 10.11.6 and VS Code 1.20.1 and Python Ext 2018.2.1