11import * as path from 'path' ;
2- import * as vscode from 'vscode' ;
3- import { Uri } from 'vscode' ;
2+ import { OutputChannel , QuickPickItem , Uri , window } from 'vscode' ;
43import { createDeferred } from '../../../common/helpers' ;
5- import { IInstaller } from '../../../common/types' ;
4+ import { IInstaller , Product } from '../../../common/types' ;
65import { getSubDirectories } from '../../../common/utils' ;
76import { ITestConfigSettingsService , UnitTestProduct } from './../types' ;
87
98export abstract class TestConfigurationManager {
109 constructor ( protected workspace : Uri ,
1110 protected product : UnitTestProduct ,
12- protected readonly outputChannel : vscode . OutputChannel ,
11+ protected readonly outputChannel : OutputChannel ,
1312 protected installer : IInstaller ,
1413 protected testConfigSettingsService : ITestConfigSettingsService ) { }
1514 // tslint:disable-next-line:no-any
1615 public abstract configure ( wkspace : Uri ) : Promise < any > ;
1716 public async enable ( ) {
17+ // Disable other test frameworks.
18+ const testProducsToDisable = [ Product . pytest , Product . unittest , Product . nosetest ]
19+ . filter ( item => item !== this . product ) as UnitTestProduct [ ] ;
20+
21+ for ( const prod of testProducsToDisable ) {
22+ await this . testConfigSettingsService . disable ( this . workspace , prod ) ;
23+ }
24+
1825 return this . testConfigSettingsService . enable ( this . workspace , this . product ) ;
1926 }
2027 // tslint:disable-next-line:no-any
2128 public async disable ( ) {
2229 return this . testConfigSettingsService . enable ( this . workspace , this . product ) ;
2330 }
24- protected selectTestDir ( rootDir : string , subDirs : string [ ] , customOptions : vscode . QuickPickItem [ ] = [ ] ) : Promise < string > {
31+ protected selectTestDir ( rootDir : string , subDirs : string [ ] , customOptions : QuickPickItem [ ] = [ ] ) : Promise < string > {
2532 const options = {
2633 matchOnDescription : true ,
2734 matchOnDetail : true ,
2835 placeHolder : 'Select the directory containing the unit tests'
2936 } ;
30- let items : vscode . QuickPickItem [ ] = subDirs
37+ let items : QuickPickItem [ ] = subDirs
3138 . map ( dir => {
3239 const dirName = path . relative ( rootDir , dir ) ;
3340 if ( dirName . indexOf ( '.' ) === 0 ) {
3441 return ;
3542 }
36- return < vscode . QuickPickItem > {
43+ return {
3744 label : dirName ,
3845 description : ''
3946 } ;
@@ -44,7 +51,7 @@ export abstract class TestConfigurationManager {
4451 items = [ { label : '.' , description : 'Root directory' } , ...items ] ;
4552 items = customOptions . concat ( items ) ;
4653 const def = createDeferred < string > ( ) ;
47- vscode . window . showQuickPick ( items , options ) . then ( item => {
54+ window . showQuickPick ( items , options ) . then ( item => {
4855 if ( ! item ) {
4956 return def . resolve ( ) ;
5057 }
@@ -61,7 +68,7 @@ export abstract class TestConfigurationManager {
6168 matchOnDetail : true ,
6269 placeHolder : 'Select the pattern to identify test files'
6370 } ;
64- const items : vscode . QuickPickItem [ ] = [
71+ const items : QuickPickItem [ ] = [
6572 { label : '*test.py' , description : 'Python Files ending with \'test\'' } ,
6673 { label : '*_test.py' , description : 'Python Files ending with \'_test\'' } ,
6774 { label : 'test*.py' , description : 'Python Files begining with \'test\'' } ,
@@ -70,7 +77,7 @@ export abstract class TestConfigurationManager {
7077 ] ;
7178
7279 const def = createDeferred < string > ( ) ;
73- vscode . window . showQuickPick ( items , options ) . then ( item => {
80+ window . showQuickPick ( items , options ) . then ( item => {
7481 if ( ! item ) {
7582 return def . resolve ( ) ;
7683 }
0 commit comments