Skip to content

pytest parameterized names split incorrectly #22000

@eleanorjboyd

Description

@eleanorjboyd

parameterized names should be split to be better rendered on the test explorer. For example this code below should have the second in between the brackets as the test names on the test explorer. For the complicated one complicated split [] () the name should be [complicated split [] ()].

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import pytest


# Testing pytest with parametrized tests. The first two pass, the third fails.
# The tests ids are parametrize_tests.py::test_adding[3+5-8] and so on.
@pytest.mark.parametrize(  # test_marker--test_adding
    "actual, expected", [("3+5", 8), ("2+4", 6), ("6+9", 16)]
)
def test_adding(actual, expected):
    assert eval(actual) == expected


# Testing pytest with parametrized tests. All three pass.
# The tests ids are parametrize_tests.py::test_under_ten[1] and so on.
@pytest.mark.parametrize(  # test_marker--test_string
    "string", ["hello", "complicated split [] ()"]
)
def test_string(string):
    assert string == "hello"

Metadata

Metadata

Assignees

Labels

area-testingbugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions