@@ -120,14 +120,17 @@ export class WorkspaceTestAdapter {
120
120
// handle token and telemetry here
121
121
sendTelemetryEvent ( EventName . UNITTEST_RUN_ALL_FAILED , undefined ) ;
122
122
123
- const cancel = token ?. isCancellationRequested
123
+ let cancel = token ?. isCancellationRequested
124
124
? Testing . cancelUnittestExecution
125
125
: Testing . errorUnittestExecution ;
126
+ if ( this . testProvider === 'pytest' ) {
127
+ cancel = token ?. isCancellationRequested ? Testing . cancelPytestExecution : Testing . errorPytestExecution ;
128
+ }
126
129
traceError ( `${ cancel } \r\n` , ex ) ;
127
130
128
131
// Also report on the test view
129
132
const message = util . format ( `${ cancel } ${ Testing . seePythonOutput } \r\n` , ex ) ;
130
- const options = buildErrorNodeOptions ( this . workspaceUri , message ) ;
133
+ const options = buildErrorNodeOptions ( this . workspaceUri , message , this . testProvider ) ;
131
134
const errorNode = createErrorTestItem ( testController , options ) ;
132
135
testController . items . add ( errorNode ) ;
133
136
@@ -310,15 +313,18 @@ export class WorkspaceTestAdapter {
310
313
} catch ( ex ) {
311
314
sendTelemetryEvent ( EventName . UNITTEST_DISCOVERY_DONE , undefined , { tool : this . testProvider , failed : true } ) ;
312
315
313
- const cancel = token ?. isCancellationRequested
316
+ let cancel = token ?. isCancellationRequested
314
317
? Testing . cancelUnittestDiscovery
315
318
: Testing . errorUnittestDiscovery ;
319
+ if ( this . testProvider === 'pytest' ) {
320
+ cancel = token ?. isCancellationRequested ? Testing . cancelPytestDiscovery : Testing . errorPytestDiscovery ;
321
+ }
316
322
317
323
traceError ( `${ cancel } \r\n` , ex ) ;
318
324
319
325
// Report also on the test view.
320
326
const message = util . format ( `${ cancel } ${ Testing . seePythonOutput } \r\n` , ex ) ;
321
- const options = buildErrorNodeOptions ( this . workspaceUri , message ) ;
327
+ const options = buildErrorNodeOptions ( this . workspaceUri , message , this . testProvider ) ;
322
328
const errorNode = createErrorTestItem ( testController , options ) ;
323
329
testController . items . add ( errorNode ) ;
324
330
@@ -336,17 +342,19 @@ export class WorkspaceTestAdapter {
336
342
337
343
// Check if there were any errors in the discovery process.
338
344
if ( rawTestData . status === 'error' ) {
345
+ const testingErrorConst =
346
+ this . testProvider === 'pytest' ? Testing . errorPytestDiscovery : Testing . errorUnittestDiscovery ;
339
347
const { errors } = rawTestData ;
340
- traceError ( Testing . errorUnittestDiscovery , '\r\n' , errors ! . join ( '\r\n\r\n' ) ) ;
348
+ traceError ( testingErrorConst , '\r\n' , errors ! . join ( '\r\n\r\n' ) ) ;
341
349
342
350
let errorNode = testController . items . get ( `DiscoveryError:${ workspacePath } ` ) ;
343
351
const message = util . format (
344
- `${ Testing . errorUnittestDiscovery } ${ Testing . seePythonOutput } \r\n` ,
352
+ `${ testingErrorConst } ${ Testing . seePythonOutput } \r\n` ,
345
353
errors ! . join ( '\r\n\r\n' ) ,
346
354
) ;
347
355
348
356
if ( errorNode === undefined ) {
349
- const options = buildErrorNodeOptions ( this . workspaceUri , message ) ;
357
+ const options = buildErrorNodeOptions ( this . workspaceUri , message , this . testProvider ) ;
350
358
errorNode = createErrorTestItem ( testController , options ) ;
351
359
testController . items . add ( errorNode ) ;
352
360
}
@@ -462,10 +470,11 @@ function populateTestTree(
462
470
} ) ;
463
471
}
464
472
465
- function buildErrorNodeOptions ( uri : Uri , message : string ) : ErrorTestItemOptions {
473
+ function buildErrorNodeOptions ( uri : Uri , message : string , testType : string ) : ErrorTestItemOptions {
474
+ const labelText = testType === 'pytest' ? 'Pytest Discovery Error' : 'Unittest Discovery Error' ;
466
475
return {
467
476
id : `DiscoveryError:${ uri . fsPath } ` ,
468
- label : `Unittest Discovery Error [${ path . basename ( uri . fsPath ) } ]` ,
477
+ label : `${ labelText } [${ path . basename ( uri . fsPath ) } ]` ,
469
478
error : message ,
470
479
} ;
471
480
}
0 commit comments