Skip to content

Commit

Permalink
remove incorrect implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd committed Jan 13, 2025
1 parent a6b69d1 commit e9dbdcc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
13 changes: 1 addition & 12 deletions python_files/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,8 @@ def pytest_report_teststatus(report, config): # noqa: ARG001
node_path = map_id_to_path[report.nodeid]
except KeyError:
node_path = cwd

# Calculate the absolute test id and use this as the ID moving forward.
absolute_node_id = get_absolute_test_id(report.nodeid, node_path)
parent_test_name = report.nodeid.split("::")[-1]
if report.head_line and report.head_line != parent_test_name:
# add parent node to collected_tests_so_far to not double report
collected_tests_so_far.append(absolute_node_id)
# If the report has a head_line, then it is a pytest-subtest
# and we need to adjust the nodeid to reflect the subtest.
if report_value == "failure":
report_value = "subtest-failure"
elif report_value == "success":
report_value = "subtest-success"
absolute_node_id = absolute_node_id + "**{" + report.head_line + "}**"
if absolute_node_id not in collected_tests_so_far:
collected_tests_so_far.append(absolute_node_id)
item_result = create_test_outcome(
Expand Down
4 changes: 2 additions & 2 deletions src/client/testing/testController/common/resultResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class PythonResultResolver implements ITestResultResolver {
}
} else if (testItem.outcome === 'subtest-failure') {
// split on [] or () based on how the subtest is setup.
const [parentTestCaseId, subtestId] = splitTestNameWithRegex(keyTemp, this.testProvider);
const [parentTestCaseId, subtestId] = splitTestNameWithRegex(keyTemp);
const parentTestItem = this.runIdToTestItem.get(parentTestCaseId);
const data = testItem;
// find the subtest's parent test item
Expand Down Expand Up @@ -288,7 +288,7 @@ export class PythonResultResolver implements ITestResultResolver {
}
} else if (testItem.outcome === 'subtest-success') {
// split on [] or () based on how the subtest is setup.
const [parentTestCaseId, subtestId] = splitTestNameWithRegex(keyTemp, this.testProvider);
const [parentTestCaseId, subtestId] = splitTestNameWithRegex(keyTemp);
const parentTestItem = this.runIdToTestItem.get(parentTestCaseId);

// find the subtest's parent test item
Expand Down
16 changes: 8 additions & 8 deletions src/client/testing/testController/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
import { Deferred, createDeferred } from '../../../common/utils/async';
import { createReaderPipe, generateRandomPipeName } from '../../../common/pipes/namedPipes';
import { EXTENSION_ROOT_DIR } from '../../../constants';
import { TestProvider } from '../../types';

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

let range: Range | undefined;
if (child.lineno) {
range = new Range(new Position(Number(child.lineno) - 1, 0), new Position(Number(child.lineno), 0));
}
let range: Range | undefined;
if (child.lineno) {
range = new Range(new Position(Number(child.lineno) - 1, 0), new Position(Number(child.lineno), 0));
Expand Down Expand Up @@ -273,15 +277,10 @@ export function createDiscoveryErrorPayload(
* @param testName The full test name string.
* @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.
*/
export function splitTestNameWithRegex(testName: string, testProvider: TestProvider): [string, string] {
export function splitTestNameWithRegex(testName: string): [string, string] {
// If a match is found, return the parent test name and the subtest (whichever was captured between parenthesis or square brackets).
// Otherwise, return the entire testName for the parent and entire testName for the subtest.
let regex: RegExp;
if (testProvider === 'pytest') {
regex = /^(.*?)\*\*{(.*?)}\*\*$/;
} else {
regex = /^(.*?) ([\[(].*[\])])$/;
}
const regex = /^(.*?) ([\[(].*[\])])$/;
const match = testName.match(regex);
if (match) {
return [match[1].trim(), match[2] || match[3] || testName];
Expand Down Expand Up @@ -351,6 +350,7 @@ export async function hasSymlinkParent(currentPath: string): Promise<boolean> {
// Recurse up the directory tree
return await hasSymlinkParent(parentDirectory);
} catch (error) {
traceError('Error checking symlinks:', error);
traceError('Error checking symlinks:', error);
return false;
}
Expand Down

0 comments on commit e9dbdcc

Please sign in to comment.