Skip to content

Test classes no longer work with pytest 6.2.5 #22457

@matthew-mcallister

Description

@matthew-mcallister

Behaviour

Expected vs. Actual

This bug occurs with pytest version 6.2.5. All tests should be visible in the Test Explorer, with classes (e.g. class TestWidget) appearing as nested levels in the hierarchy.

However, if a test class is present (or multiple test classes), all other tests are hidden except for the tests in that class.

Steps to reproduce:

  1. Define a test file test_example.py with the following text:
    def test_one():
        pass
    
    class TestExample:
        def test_two():
            pass
  2. Run test discovery in the Test Explorer.
  3. Only test_two is visible.
  4. If you delete TestExample, then test_one becomes visible again.

Diagnostic data

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

  <Module test_example.py>
    <Function test_outer>
2023-11-09 15:40:25.183 [info] 
    <Class TestClass>
        <Function test_inner>

User Settings


languageServer: "Pylance"

testing
• pytestArgs: "-vv"
• pytestEnabled: true

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions