@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
33import { Tests , CANCELLATION_REASON } from '../common/contracts' ;
44import * as constants from '../../common/constants' ;
55import { displayTestErrorMessage } from '../common/testUtils' ;
6- import { isNotInstalledError } from '../../common/helpers' ;
6+ import { isNotInstalledError , createDeferred } from '../../common/helpers' ;
77
88export class TestResultDisplay {
99 private statusBar : vscode . StatusBarItem ;
@@ -120,6 +120,24 @@ export class TestResultDisplay {
120120 } ) ;
121121 }
122122
123+ private disableTests ( ) : Promise < any > {
124+ const def = createDeferred < any > ( ) ;
125+ const pythonConfig = vscode . workspace . getConfiguration ( 'python' ) ;
126+ let settingsToDisable = [ 'unitTest.promptToConfigure' , 'unitTest.pyTestEnabled' ,
127+ 'unitTest.unittestEnabled' , 'unitTest.nosetestsEnabled' ] ;
128+
129+ function disableTest ( ) {
130+ if ( settingsToDisable . length === 0 ) {
131+ return def . resolve ( ) ;
132+ }
133+ pythonConfig . update ( settingsToDisable . shift ( ) , false )
134+ . then ( disableTest . bind ( this ) , disableTest . bind ( this ) ) ;
135+ }
136+
137+ disableTest ( ) ;
138+ return def . promise ;
139+ }
140+
123141 private updateWithDiscoverSuccess ( tests : Tests ) {
124142 this . clearProgressTicker ( ) ;
125143 const haveTests = tests && ( tests . testFunctions . length > 0 ) ;
@@ -129,7 +147,11 @@ export class TestResultDisplay {
129147 this . statusBar . show ( ) ;
130148
131149 if ( ! haveTests ) {
132- vscode . window . showInformationMessage ( 'No tests discovered, please check the configuration settings for the tests.' ) ;
150+ vscode . window . showInformationMessage ( 'No tests discovered, please check the configuration settings for the tests.' , 'Disable Tests' ) . then ( item => {
151+ if ( item === 'Disable Tests' ) {
152+ this . disableTests ( ) ;
153+ }
154+ } ) ;
133155 }
134156 }
135157
0 commit comments