When a unittest subTest fails, it says that no tests ran
See original GitHub issueEnvironment data
- VS Code version: 1.33.1
- Extension version (available under the Extensions sidebar): 2019.4.11987
- OS and version: Ubuntu 16.04
- Python version (& distribution if applicable, e.g. Anaconda): 3.5.2
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv
- Relevant/affected Python packages and their versions: N/A
Expected behaviour
Expected to see the tests fail, and have VS Code show that it failed.
Actual behaviour
Does not indicate if the test succeeded or failed, even though the logs clearly indicate that the test was run and it failed. The status bar at the bottom of the screen says “No Tests Run”. A warning notification pops up saying that no tests were run.
Steps to reproduce:
- Create an empty folder and open it in VS Code
- Create a file named
test_failing_subtests.py
with the contents:
import unittest
class TestFailingSubtests(unittest.TestCase):
def test_failing_subtest(self):
with self.subTest():
self.fail()
def test_failing_subtest_with_msg(self):
with self.subTest("Placeholder message"):
self.fail()
if __name__ == '__main__':
unittest.main()
- Set up the VS Code configuration so that it discovers the test
- In the command palette, run
Python: Discover Tests
- In the command palette, run
Python: Run All Tests
Logs
Output for Python Test Log
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python Test Log
)
start
test_fail_subtests.TestFailingSubtests.test_failing_subtest
test_fail_subtests.TestFailingSubtests.test_failing_subtest_with_msg
test_failing_subtest (test_fail_subtests.TestFailingSubtests) ... test_failing_subtest_with_msg (test_fail_subtests.TestFailingSubtests) ...
======================================================================
FAIL: test_failing_subtest (test_fail_subtests.TestFailingSubtests) (<subtest>)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/vscode-python-subtest-bug/test_fail_subtests.py", line 7, in test_failing_subtest
self.fail()
AssertionError: None
======================================================================
FAIL: test_failing_subtest_with_msg (test_fail_subtests.TestFailingSubtests) [Placeholder message]
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/vscode-python-subtest-bug/test_fail_subtests.py", line 11, in test_failing_subtest_with_msg
self.fail()
AssertionError: None
----------------------------------------------------------------------
Ran 2 tests in 0.001s
FAILED (failures=2)
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging
)
[Extension Host] Python Extension: Cached data exists ActivatedEnvironmentVariables, /tmp/vscode-python-subtest-bug
console.ts:134 [Extension Host] Python Extension: getActivatedEnvironmentVariables, Class name = S, Arg 1: <Uri:/tmp/vscode-python-subtest-bug>, Arg 2: undefined, Arg 3: undefined
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /tmp/vscode-python-subtest-bug
console.ts:134 [Extension Host] Python Extension: Cached data exists ActivatedEnvironmentVariables, /tmp/vscode-python-subtest-bug
console.ts:134 [Extension Host] Python Extension: getActivatedEnvironmentVariables, Class name = S, Arg 1: <Uri:/tmp/vscode-python-subtest-bug>, Arg 2: undefined, Arg 3: undefined
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, /tmp/vscode-python-subtest-bug
I’d be happy to take a stab at fixing this if somebody could point me in the right direction.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Any updates on this?
Closing as duplicate of #17561.