@@ -120,14 +120,17 @@ export class WorkspaceTestAdapter {
120120 // handle token and telemetry here
121121 sendTelemetryEvent ( EventName . UNITTEST_RUN_ALL_FAILED , undefined ) ;
122122
123- const cancel = token ?. isCancellationRequested
123+ let cancel = token ?. isCancellationRequested
124124 ? Testing . cancelUnittestExecution
125125 : Testing . errorUnittestExecution ;
126+ if ( this . testProvider === 'pytest' ) {
127+ cancel = token ?. isCancellationRequested ? Testing . cancelPytestExecution : Testing . errorPytestExecution ;
128+ }
126129 traceError ( `${ cancel } \r\n` , ex ) ;
127130
128131 // Also report on the test view
129132 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 ) ;
131134 const errorNode = createErrorTestItem ( testController , options ) ;
132135 testController . items . add ( errorNode ) ;
133136
@@ -310,15 +313,18 @@ export class WorkspaceTestAdapter {
310313 } catch ( ex ) {
311314 sendTelemetryEvent ( EventName . UNITTEST_DISCOVERY_DONE , undefined , { tool : this . testProvider , failed : true } ) ;
312315
313- const cancel = token ?. isCancellationRequested
316+ let cancel = token ?. isCancellationRequested
314317 ? Testing . cancelUnittestDiscovery
315318 : Testing . errorUnittestDiscovery ;
319+ if ( this . testProvider === 'pytest' ) {
320+ cancel = token ?. isCancellationRequested ? Testing . cancelPytestDiscovery : Testing . errorPytestDiscovery ;
321+ }
316322
317323 traceError ( `${ cancel } \r\n` , ex ) ;
318324
319325 // Report also on the test view.
320326 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 ) ;
322328 const errorNode = createErrorTestItem ( testController , options ) ;
323329 testController . items . add ( errorNode ) ;
324330
@@ -336,17 +342,19 @@ export class WorkspaceTestAdapter {
336342
337343 // Check if there were any errors in the discovery process.
338344 if ( rawTestData . status === 'error' ) {
345+ const testingErrorConst =
346+ this . testProvider === 'pytest' ? Testing . errorPytestDiscovery : Testing . errorUnittestDiscovery ;
339347 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' ) ) ;
341349
342350 let errorNode = testController . items . get ( `DiscoveryError:${ workspacePath } ` ) ;
343351 const message = util . format (
344- `${ Testing . errorUnittestDiscovery } ${ Testing . seePythonOutput } \r\n` ,
352+ `${ testingErrorConst } ${ Testing . seePythonOutput } \r\n` ,
345353 errors ! . join ( '\r\n\r\n' ) ,
346354 ) ;
347355
348356 if ( errorNode === undefined ) {
349- const options = buildErrorNodeOptions ( this . workspaceUri , message ) ;
357+ const options = buildErrorNodeOptions ( this . workspaceUri , message , this . testProvider ) ;
350358 errorNode = createErrorTestItem ( testController , options ) ;
351359 testController . items . add ( errorNode ) ;
352360 }
@@ -462,10 +470,11 @@ function populateTestTree(
462470 } ) ;
463471}
464472
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' ;
466475 return {
467476 id : `DiscoveryError:${ uri . fsPath } ` ,
468- label : `Unittest Discovery Error [${ path . basename ( uri . fsPath ) } ]` ,
477+ label : `${ labelText } [${ path . basename ( uri . fsPath ) } ]` ,
469478 error : message ,
470479 } ;
471480}
0 commit comments