Skip to content

Commit 55bbcd8

Browse files
Compose IPythonTestMessage from ITestPassingMessage and ITestNonPassingMessage.
1 parent dd879e7 commit 55bbcd8

2 files changed

Lines changed: 21 additions & 22 deletions

File tree

src/client/testing/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,7 @@ export interface ITestNonPassingMessage extends IPythonTestMessageCommon {
207207
traceback?: string;
208208
locationStack: ILocationStackFrameDetails[];
209209
}
210-
//export type IPythonTestMessage = ITestPassMessage | ITestFailMessage;
211-
export interface IPythonTestMessage extends IPythonTestMessageCommon {
212-
message?: string;
213-
traceback?: string;
214-
locationStack?: ILocationStackFrameDetails[];
215-
}
210+
export type IPythonTestMessage = ITestPassingMessage | ITestNonPassingMessage;
216211

217212
export interface ILocationStackFrameDetails {
218213
location: Location;

src/test/testing/pytest/pytest.testMessageService.test.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { TestMessageService } from '../../../client/testing/pytest/services/test
3232
import {
3333
ILocationStackFrameDetails,
3434
IPythonTestMessage,
35+
ITestNonPassingMessage,
3536
PythonTestMessageSeverity,
3637
} from '../../../client/testing/types';
3738
import { rootWorkspaceUri, updateSetting } from '../../common';
@@ -60,45 +61,47 @@ async function testMessageProperties(
6061
imported: boolean = false,
6162
status: TestStatus,
6263
) {
64+
const nonPassing = message as ITestNonPassingMessage;
65+
const expectedNonPassing = expectedMessage as ITestNonPassingMessage;
6366
assert.equal(message.code, expectedMessage.code, 'IPythonTestMessage code');
64-
assert.equal(message.message, expectedMessage.message, 'IPythonTestMessage message');
67+
assert.equal(nonPassing.message, expectedNonPassing.message, 'IPythonTestMessage message');
6568
assert.equal(message.severity, expectedMessage.severity, 'IPythonTestMessage severity');
6669
assert.equal(message.provider, expectedMessage.provider, 'IPythonTestMessage provider');
6770
assert.isNumber(message.testTime, 'IPythonTestMessage testTime');
6871
assert.equal(message.status, expectedMessage.status, 'IPythonTestMessage status');
6972
assert.equal(message.testFilePath, expectedMessage.testFilePath, 'IPythonTestMessage testFilePath');
7073
if (status !== TestStatus.Pass) {
7174
assert.equal(
72-
message.locationStack![0].lineText,
73-
expectedMessage.locationStack![0].lineText,
75+
nonPassing.locationStack[0].lineText,
76+
expectedNonPassing.locationStack[0].lineText,
7477
'IPythonTestMessage line text',
7578
);
7679
assert.equal(
77-
message.locationStack![0].location.uri.fsPath,
78-
expectedMessage.locationStack![0].location.uri.fsPath,
80+
nonPassing.locationStack[0].location.uri.fsPath,
81+
expectedNonPassing.locationStack[0].location.uri.fsPath,
7982
'IPythonTestMessage locationStack fsPath',
8083
);
8184
if (status !== TestStatus.Skipped) {
8285
assert.equal(
83-
message.locationStack![1].lineText,
84-
expectedMessage.locationStack![1].lineText,
86+
nonPassing.locationStack[1].lineText,
87+
expectedNonPassing.locationStack[1].lineText,
8588
'IPythonTestMessage line text',
8689
);
8790
assert.equal(
88-
message.locationStack![1].location.uri.fsPath,
89-
expectedMessage.locationStack![1].location.uri.fsPath,
91+
nonPassing.locationStack[1].location.uri.fsPath,
92+
expectedNonPassing.locationStack[1].location.uri.fsPath,
9093
'IPythonTestMessage locationStack fsPath',
9194
);
9295
}
9396
if (imported) {
9497
assert.equal(
95-
message.locationStack![2].lineText,
96-
expectedMessage.locationStack![2].lineText,
98+
nonPassing.locationStack[2].lineText,
99+
expectedNonPassing.locationStack[2].lineText,
97100
'IPythonTestMessage imported line text',
98101
);
99102
assert.equal(
100-
message.locationStack![2].location.uri.fsPath,
101-
expectedMessage.locationStack![2].location.uri.fsPath,
103+
nonPassing.locationStack[2].location.uri.fsPath,
104+
expectedNonPassing.locationStack[2].location.uri.fsPath,
102105
'IPythonTestMessage imported location fsPath',
103106
);
104107
}
@@ -229,14 +232,15 @@ suite('Unit Tests - PyTest - TestMessageService', () => {
229232
const expectedLocationStack = await getExpectedLocationStackFromTestDetails(td);
230233
expectedMessage = {
231234
code: td.nameToRun,
232-
message: td.message,
233235
severity: expectedSeverity,
234236
provider: ProductNames.get(Product.pytest)!,
235237
testTime: 0,
236238
status: td.status as FinalTestStatus,
237-
locationStack: expectedLocationStack,
238239
testFilePath: path.join(UNITTEST_TEST_FILES_PATH, td.fileName),
239-
};
240+
// These are non-passing properties only:
241+
message: td.message,
242+
locationStack: expectedLocationStack,
243+
} as IPythonTestMessage;
240244
testMessage = testMessages.find((tm) => tm.code === td.nameToRun)!;
241245
});
242246
test('Message', async () => {

0 commit comments

Comments
 (0)