Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions python_files/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TestItem(TestData):

lineno: str
runID: str
tags: list[str]


class TestNode(TestData):
Expand Down Expand Up @@ -816,13 +817,22 @@ def create_test_node(
str(test_case.location[1] + 1) if (test_case.location[1] is not None) else ""
)
absolute_test_id = get_absolute_test_id(test_case.nodeid, get_node_path(test_case))

# Extract pytest marks as tags
tags: list[str] = []
if hasattr(test_case, "own_markers"):
for marker in test_case.own_markers:
if marker.name and marker.name != "parametrize":
tags.append(marker.name)

return {
"name": test_case.name,
"path": get_node_path(test_case),
"lineno": test_case_loc,
"type_": "test",
"id_": absolute_test_id,
"runID": absolute_test_id,
"tags": tags,
}


Expand Down
1 change: 1 addition & 0 deletions src/client/testing/testController/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export type DiscoveredTestCommon = {
export type DiscoveredTestItem = DiscoveredTestCommon & {
lineno: number | string;
runID: string;
tags?: string[];
};

export type DiscoveredTestNode = DiscoveredTestCommon & {
Expand Down
6 changes: 4 additions & 2 deletions src/client/testing/testController/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ export function populateTestTree(
if (!token?.isCancellationRequested) {
if (isTestItem(child)) {
const testItem = testController.createTestItem(child.id_, child.name, Uri.file(child.path));
testItem.tags = [RunTestTag, DebugTestTag];

// Create tags from pytest marks (if available) and combine with default tags
const pytestMarkTags = (child.tags ?? []).map((tag) => ({ id: `mark.${tag}` }));
testItem.tags = [RunTestTag, DebugTestTag, ...pytestMarkTags];

let range: Range | undefined;
if (child.lineno) {
Expand All @@ -242,7 +245,6 @@ export function populateTestTree(
}
testItem.canResolveChildren = false;
testItem.range = range;
testItem.tags = [RunTestTag, DebugTestTag];

testRoot!.children.add(testItem);
// add to our map
Expand Down