Skip to content

Commit 16e521d

Browse files
andravinclaude
andcommitted
fix(testing): deduplicate pytest marks when extracting tags
Prevents duplicate tags when the same marker is applied multiple times or through plugin interactions. Uses dict.fromkeys() to preserve order while deduplicating. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bfd57b0 commit 16e521d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

python_files/vscode_pytest/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,11 @@ def create_test_node(
837837
)
838838
absolute_test_id = get_absolute_test_id(test_case.nodeid, get_node_path(test_case))
839839

840-
# Extract pytest marks as tags
841-
tags: list[str] = []
842-
if hasattr(test_case, "own_markers"):
843-
for marker in test_case.own_markers:
844-
if marker.name and marker.name != "parametrize":
845-
tags.append(marker.name)
840+
# Extract pytest marks as tags (deduplicated, preserving order)
841+
tags: list[str] = list(dict.fromkeys(
842+
marker.name for marker in (getattr(test_case, "own_markers", None) or [])
843+
if marker.name and marker.name != "parametrize"
844+
))
846845

847846
return {
848847
"name": test_case.name,

0 commit comments

Comments
 (0)