Skip to content

Commit 71bc1ca

Browse files
author
Kartik Raj
committed
more corrections
1 parent f70e671 commit 71bc1ca

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/client/unittests/explorer/commandHandlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import { ITestDataItemResource, TestDataItem } from '../types';
2121
const testNavigationCommandMapping = {
2222
[TestType.testFile]: Commands.navigateToTestFile,
2323
[TestType.testFunction]: Commands.navigateToTestFunction,
24-
[TestType.testSuite]: Commands.navigateToTestSuite
24+
[TestType.testSuite]: Commands.navigateToTestSuite,
25+
[TestType.testFolder]: undefined
2526
};
2627

2728
@injectable()

src/client/unittests/pytest/services/testMessageService.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ export class TestMessageService implements ITestMessageService {
107107
testSourceFilePath = path.isAbsolute(testSourceFilePath) ? testSourceFilePath : path.resolve(rootDirectory, testSourceFilePath);
108108
const testSourceFileUri = Uri.file(testSourceFilePath);
109109
const testSourceFile = await workspace.openTextDocument(testSourceFileUri);
110-
let testDefLine: TextLine | undefined;
110+
let testDefLine: TextLine | null = null;
111111
let lineNum = testFunction.testFunction.line!;
112112
let lineText: string = '';
113113
let trimmedLineText: string = '';
114114
const testDefPrefix = 'def ';
115115
const testAsyncDefPrefix = 'async def ';
116116
let prefix = '';
117-
while (testDefLine === undefined) {
117+
118+
while (testDefLine === null) {
118119
const possibleTestDefLine = testSourceFile.lineAt(lineNum);
119120
lineText = possibleTestDefLine.text;
120121
trimmedLineText = lineText.trimLeft()!;
@@ -204,7 +205,7 @@ export class TestMessageService implements ITestMessageService {
204205
const lineClassName = matches ? matches[0] : undefined;
205206

206207
// Check if the indentation is proper.
207-
if (parentIndentation === undefined) {
208+
if (parentIndentation === -1) {
208209
// The parentIndentation hasn't been set yet, so we are looking for a class that was
209210
// defined in the global scope of the module.
210211
if (trimmedLineText.length === lineText.length) {
@@ -227,7 +228,7 @@ export class TestMessageService implements ITestMessageService {
227228
parentScopeEndIndex = index + 1;
228229
continue;
229230
}
230-
if (prevLowestIndentation === undefined || indentation < prevLowestIndentation) {
231+
if (prevLowestIndentation === -1 || indentation < prevLowestIndentation) {
231232
if (lineClassName === suiteName) {
232233
// This might be the line that we want.
233234
suiteDefLineIndex = index;
@@ -239,19 +240,19 @@ export class TestMessageService implements ITestMessageService {
239240
}
240241
}
241242
}
242-
if (suiteDefLineIndex === undefined) {
243+
if (suiteDefLineIndex === -1) {
243244
// Could not find the suite declaration line, so give up and move on with the latest one that we found.
244245
break;
245246
}
246247
// Found the line to process.
247248
parentScopeStartIndex = suiteDefLineIndex;
248-
parentIndentation = indentation;
249+
parentIndentation = indentation!;
249250

250251
// Invert the index to get the unreversed equivalent.
251252
const realIndex = (reversedTestFileLines.length - 1) - suiteDefLineIndex;
252-
const startChar = indentation + classPrefix.length;
253+
const startChar = indentation! + classPrefix.length;
253254
const suiteStartPos = new Position(realIndex, startChar);
254-
const suiteEndPos = new Position(realIndex, (startChar + suiteName.length));
255+
const suiteEndPos = new Position(realIndex, (startChar + suiteName!.length));
255256
const suiteRange = new Range(suiteStartPos, suiteEndPos);
256257
const suiteLocation = new Location(testFileUri, suiteRange);
257258
suiteLocationStackFrameDetails.push({ location: suiteLocation, lineText: testFile.getText(suiteRange) });

src/client/unittests/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export interface IPythonUnitTestMessage {
133133
provider: string | undefined;
134134
traceback?: string;
135135
testTime: number;
136-
status: TestStatus;
136+
status?: TestStatus;
137137
locationStack?: ILocationStackFrameDetails[];
138138
testFilePath: string;
139139
}

0 commit comments

Comments
 (0)