Skip to content

Commit e9dbdcc

Browse files
committed
remove incorrect implementation
1 parent a6b69d1 commit e9dbdcc

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

python_files/vscode_pytest/__init__.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,19 +271,8 @@ def pytest_report_teststatus(report, config): # noqa: ARG001
271271
node_path = map_id_to_path[report.nodeid]
272272
except KeyError:
273273
node_path = cwd
274-
274+
# Calculate the absolute test id and use this as the ID moving forward.
275275
absolute_node_id = get_absolute_test_id(report.nodeid, node_path)
276-
parent_test_name = report.nodeid.split("::")[-1]
277-
if report.head_line and report.head_line != parent_test_name:
278-
# add parent node to collected_tests_so_far to not double report
279-
collected_tests_so_far.append(absolute_node_id)
280-
# If the report has a head_line, then it is a pytest-subtest
281-
# and we need to adjust the nodeid to reflect the subtest.
282-
if report_value == "failure":
283-
report_value = "subtest-failure"
284-
elif report_value == "success":
285-
report_value = "subtest-success"
286-
absolute_node_id = absolute_node_id + "**{" + report.head_line + "}**"
287276
if absolute_node_id not in collected_tests_so_far:
288277
collected_tests_so_far.append(absolute_node_id)
289278
item_result = create_test_outcome(

src/client/testing/testController/common/resultResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class PythonResultResolver implements ITestResultResolver {
246246
}
247247
} else if (testItem.outcome === 'subtest-failure') {
248248
// split on [] or () based on how the subtest is setup.
249-
const [parentTestCaseId, subtestId] = splitTestNameWithRegex(keyTemp, this.testProvider);
249+
const [parentTestCaseId, subtestId] = splitTestNameWithRegex(keyTemp);
250250
const parentTestItem = this.runIdToTestItem.get(parentTestCaseId);
251251
const data = testItem;
252252
// find the subtest's parent test item
@@ -288,7 +288,7 @@ export class PythonResultResolver implements ITestResultResolver {
288288
}
289289
} else if (testItem.outcome === 'subtest-success') {
290290
// split on [] or () based on how the subtest is setup.
291-
const [parentTestCaseId, subtestId] = splitTestNameWithRegex(keyTemp, this.testProvider);
291+
const [parentTestCaseId, subtestId] = splitTestNameWithRegex(keyTemp);
292292
const parentTestItem = this.runIdToTestItem.get(parentTestCaseId);
293293

294294
// find the subtest's parent test item

src/client/testing/testController/common/utils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
import { Deferred, createDeferred } from '../../../common/utils/async';
1919
import { createReaderPipe, generateRandomPipeName } from '../../../common/pipes/namedPipes';
2020
import { EXTENSION_ROOT_DIR } from '../../../constants';
21-
import { TestProvider } from '../../types';
2221

2322
export function fixLogLinesNoTrailing(content: string): string {
2423
const lines = content.split(/\r?\n/g);
@@ -90,6 +89,7 @@ export async function startRunResultNamedPipe(
9089
if (cancellationToken) {
9190
disposables.push(
9291
cancellationToken?.onCancellationRequested(() => {
92+
traceLog(`Test Result named pipe ${pipeName} cancelled`);
9393
traceLog(`Test Result named pipe ${pipeName} cancelled`);
9494
disposable.dispose();
9595
}),
@@ -196,6 +196,10 @@ export function populateTestTree(
196196
const testItem = testController.createTestItem(child.id_, child.name, Uri.file(child.path));
197197
testItem.tags = [RunTestTag, DebugTestTag];
198198

199+
let range: Range | undefined;
200+
if (child.lineno) {
201+
range = new Range(new Position(Number(child.lineno) - 1, 0), new Position(Number(child.lineno), 0));
202+
}
199203
let range: Range | undefined;
200204
if (child.lineno) {
201205
range = new Range(new Position(Number(child.lineno) - 1, 0), new Position(Number(child.lineno), 0));
@@ -273,15 +277,10 @@ export function createDiscoveryErrorPayload(
273277
* @param testName The full test name string.
274278
* @returns A tuple where the first item is the parent test name and the second item is the subtest section or `testName` if no subtest section exists.
275279
*/
276-
export function splitTestNameWithRegex(testName: string, testProvider: TestProvider): [string, string] {
280+
export function splitTestNameWithRegex(testName: string): [string, string] {
277281
// If a match is found, return the parent test name and the subtest (whichever was captured between parenthesis or square brackets).
278282
// Otherwise, return the entire testName for the parent and entire testName for the subtest.
279-
let regex: RegExp;
280-
if (testProvider === 'pytest') {
281-
regex = /^(.*?)\*\*{(.*?)}\*\*$/;
282-
} else {
283-
regex = /^(.*?) ([\[(].*[\])])$/;
284-
}
283+
const regex = /^(.*?) ([\[(].*[\])])$/;
285284
const match = testName.match(regex);
286285
if (match) {
287286
return [match[1].trim(), match[2] || match[3] || testName];
@@ -351,6 +350,7 @@ export async function hasSymlinkParent(currentPath: string): Promise<boolean> {
351350
// Recurse up the directory tree
352351
return await hasSymlinkParent(parentDirectory);
353352
} catch (error) {
353+
traceError('Error checking symlinks:', error);
354354
traceError('Error checking symlinks:', error);
355355
return false;
356356
}

0 commit comments

Comments
 (0)