Skip to content

Unit Tests with unittest do not show as failed if the setUpClass method raises an exception #21826

Description

@kaysond

Type: Bug

Behaviour

Expected vs. Actual

Expected: If the setUpClass method raises an exception, all unit tests should fail
Actual: Unit tests do not fail (I think it actually just preserves the previous test result without a setUpClass method)

Steps to reproduce:

  1. Create the below python file
  2. Run the tests as is, it should succeed
  3. Uncomment the exception and comment the pass
  4. Run again
import unittest


class TestVSCode(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        pass
        #raise Exception

    def test_something(self):
        self.assertTrue(True)

Redacted some info below but if you can't reproduce please let me know.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.1
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


envFile: "<placeholder>"

languageServer: "Pylance"

linting
• pylintPath: "<placeholder>"

formatting
• provider: "black"
• blackPath: "<placeholder>"

testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true

Extension version: 2023.14.0
VS Code version: Code 1.80.0 (660393deaaa6d1996740ff4880f1bad43768c814, 2023-07-04T15:06:02.407Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.4.0-92-generic

Metadata

Metadata

Assignees

Labels

area-testingbugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked on

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions