Skip to content

Cannot debug single unit test anymore #2241

@F4h4D-T-Q

Description

@F4h4D-T-Q

Environment data

  • VS Code version: 1.25.1
  • Extension version (available under the Extensions sidebar): 2018.7.1
  • OS and version: Windows 7 (also tried on Windows 10)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: Unit Testing

Actual behavior

Clicking on the 'Debug Test' link of a unit test method (not class!) results in all the unit tests of that class to execute.
Quick analysis:
The problem stems from the code change in #2066 on line 300, where a 'break' has been added in the first condition. Removing this makes the code work as before.

It also seems that the second condition (line 301) will never be reached due to this 'break'. This is because the first condition (line 298) is a more lenient check and will always be true when the second more stricter check is true. Unfortunately due to the 'break' the first condition will assign the whole class as the desired tests instead of the single test, which is assigned if he second condition is true.

Expected behavior

Only the selected unit test method should execute, as was the case earlier.

Steps to reproduce:

  1. Create a unit test class (derived from unittest.TestCase)
  2. Create a couple of unit test methods.
  3. Assuming that the unit tests are discovered and the 'Run Test| Debug Test' links are visible, click on the Debug Test link of a method. --> All the Unit tests execute instead of only the desired test.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

N/A, please see issue above

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

N/A, please see issue above

Metadata

Metadata

Assignees

Labels

area-debuggingbugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions