Skip to content

Commit 84c9e66

Browse files
committed
fix naming of tests displayed
1 parent f115cbf commit 84c9e66

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pythonFiles/tests/pytestadapter/expected_discovery_test_output.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@
389389
# This is the expected output for the nested_folder tests.
390390
# └── parametrize_tests.py
391391
# └── test_adding
392-
# └── test_adding[3+5-8]
393-
# └── test_adding[2+4-6]
394-
# └── test_adding[6+9-16]
392+
# └── [3+5-8]
393+
# └── [2+4-6]
394+
# └── [6+9-16]
395395
parameterize_tests_path = os.fspath(TEST_DATA_PATH / "parametrize_tests.py")
396396
parametrize_tests_expected_output = {
397397
"name": ".data",
@@ -411,7 +411,7 @@
411411
"id_": "parametrize_tests.py::test_adding",
412412
"children": [
413413
{
414-
"name": "test_adding[3+5-8]",
414+
"name": "[3+5-8]",
415415
"path": parameterize_tests_path,
416416
"lineno": find_test_line_number(
417417
"test_adding[3+5-8]",
@@ -422,7 +422,7 @@
422422
"runID": "parametrize_tests.py::test_adding[3+5-8]",
423423
},
424424
{
425-
"name": "test_adding[2+4-6]",
425+
"name": "[2+4-6]",
426426
"path": parameterize_tests_path,
427427
"lineno": find_test_line_number(
428428
"test_adding[2+4-6]",
@@ -433,7 +433,7 @@
433433
"runID": "parametrize_tests.py::test_adding[2+4-6]",
434434
},
435435
{
436-
"name": "test_adding[6+9-16]",
436+
"name": "[6+9-16]",
437437
"path": parameterize_tests_path,
438438
"lineno": find_test_line_number(
439439
"test_adding[6+9-16]",

pythonFiles/vscode_pytest/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ def build_test_tree(session: pytest.Session) -> TestNode:
257257
test_file_node["children"].append(test_class_node)
258258
elif hasattr(test_case, "callspec"): # This means it is a parameterized test.
259259
function_name: str = ""
260+
# parameterized test cases cut the repetitive part of the name off.
261+
name_split = test_node["name"].split("[")[1]
262+
test_node["name"] = "[" + name_split
260263
try:
261264
function_name = test_case.originalname # type: ignore
262265
function_test_case = function_nodes_dict[function_name]

0 commit comments

Comments
 (0)