Skip to content

Commit 876b01a

Browse files
committed
fix #559
1 parent 6c4a4b5 commit 876b01a

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

  • src/client/unittests/display

src/client/unittests/display/main.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
33
import { Tests, CANCELLATION_REASON } from '../common/contracts';
44
import * as constants from '../../common/constants';
55
import { displayTestErrorMessage } from '../common/testUtils';
6-
import { isNotInstalledError } from '../../common/helpers';
6+
import { isNotInstalledError, createDeferred } from '../../common/helpers';
77

88
export 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

Comments
 (0)