Skip to content

Parametrized class tests are not properly shown #23434

@lipaun

Description

@lipaun

Type: Bug

Behaviour

When a file have multiple test classes with same test methods and those methods are parametrized, the testing tool shows mixed params.

Steps to reproduce:

Given this example:

import pytest


class TestNotEmpty:
    @pytest.mark.parametrize("a, b", [(1, 1), (2, 2)])
    def test_integer(self, a, b):
        assert a == b

    @pytest.mark.parametrize("a, b", [("a", "a"), ("b", "b")])
    def test_string(self, a, b):
        assert a == b


class TestEmpty:
    @pytest.mark.parametrize("a, b", [(0, 0)])
    def test_integer(self, a, b):
        assert a == b

    @pytest.mark.parametrize("a, b", [("", "")])
    def test_string(self, a, b):
        assert a == b

the testing tool shows it like:
image

While test discover output is:

rootdir: /Users/user/Downloads/tester_issue
collected 6 items

<Dir tester_issue>
  <Module test_tester.py>
    <Class TestNotEmpty>
      <Function test_integer[1-1]>
      <Function test_integer[2-2]>
      <Function test_string[a-a]>
      <Function test_string[b-b]>
    <Class TestEmpty>
      <Function test_integer[0-0]>
      <Function test_string[-]>

Diagnostic data

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

XXX

Extension version: 2024.6.0
VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:14:32.757Z)
OS version: Darwin arm64 21.6.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Pylance
User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Installed Extensions
Extension Name Extension Id Version
Black Formatter ms-python.black-formatter 2024.2.0
JavaScript Debugger ms-vscode.js-debug 1.89.0
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.2
Pylance ms-python.vscode-pylance 2024.5.1
Python ms-python.python 2024.6.0
Python Debugger ms-python.debugpy 2024.6.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.9
System Info
Item Value
CPUs Apple M1 (8 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (2.69GB free)
Process Argv
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
tftest:31042121
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
vscaat:30438848
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
chatpanelc:31018788
dsvsc021:30996838
0ee40948:31013168
pythoncenvptcf:31043158
fchga941:31046352
dvdeprecation:31040881
dwnewjupyter:31046869

Metadata

Metadata

Assignees

Labels

area-testinginfo-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions