@@ -29,7 +29,8 @@ suite('Activated Env Launch', async () => {
2929 let activatedEnvLaunch : ActivatedEnvironmentLaunch ;
3030 let _promptIfApplicable : sinon . SinonStub ;
3131
32- suite ( 'Method getPrefixOfSelectedActivatedEnv()' , ( ) => {
32+ suite ( 'Method selectIfLaunchedViaActivatedEnv()' , ( ) => {
33+ const oldVSCodeCLI = process . env . VSCODE_CLI ;
3334 const oldCondaPrefix = process . env . CONDA_PREFIX ;
3435 const oldCondaShlvl = process . env . CONDA_SHLVL ;
3536 const oldVirtualEnv = process . env . VIRTUAL_ENV ;
@@ -41,6 +42,7 @@ suite('Activated Env Launch', async () => {
4142 processServiceFactory = TypeMoq . Mock . ofType < IProcessServiceFactory > ( ) ;
4243 _promptIfApplicable = sinon . stub ( ActivatedEnvironmentLaunch . prototype , '_promptIfApplicable' ) ;
4344 _promptIfApplicable . returns ( Promise . resolve ( ) ) ;
45+ process . env . VSCODE_CLI = '1' ;
4446 } ) ;
4547
4648 teardown ( ( ) => {
@@ -59,6 +61,11 @@ suite('Activated Env Launch', async () => {
5961 } else {
6062 delete process . env . VIRTUAL_ENV ;
6163 }
64+ if ( oldVSCodeCLI ) {
65+ process . env . VSCODE_CLI = oldVSCodeCLI ;
66+ } else {
67+ delete process . env . VSCODE_CLI ;
68+ }
6269 sinon . restore ( ) ;
6370 } ) ;
6471
@@ -94,6 +101,39 @@ suite('Activated Env Launch', async () => {
94101 pythonPathUpdaterService . verifyAll ( ) ;
95102 } ) ;
96103
104+ test ( 'Does not update interpreter path if VSCode is not launched via CLI' , async ( ) => {
105+ delete process . env . VSCODE_CLI ;
106+ process . env . CONDA_PREFIX = condaPrefix ;
107+ process . env . CONDA_SHLVL = '1' ;
108+ interpreterService
109+ . setup ( ( i ) => i . getInterpreterDetails ( TypeMoq . It . isAny ( ) ) )
110+ . returns ( ( ) => Promise . resolve ( ( { envName : 'env' } as unknown ) as PythonEnvironment ) ) ;
111+ workspaceService . setup ( ( w ) => w . workspaceFile ) . returns ( ( ) => undefined ) ;
112+ const workspaceFolder : WorkspaceFolder = { name : 'one' , uri, index : 0 } ;
113+ workspaceService . setup ( ( w ) => w . workspaceFolders ) . returns ( ( ) => [ workspaceFolder ] ) ;
114+ pythonPathUpdaterService
115+ . setup ( ( p ) =>
116+ p . updatePythonPath (
117+ TypeMoq . It . isValue ( condaPrefix ) ,
118+ TypeMoq . It . isValue ( ConfigurationTarget . WorkspaceFolder ) ,
119+ TypeMoq . It . isValue ( 'load' ) ,
120+ TypeMoq . It . isValue ( uri ) ,
121+ ) ,
122+ )
123+ . returns ( ( ) => Promise . resolve ( ) )
124+ . verifiable ( TypeMoq . Times . never ( ) ) ;
125+ activatedEnvLaunch = new ActivatedEnvironmentLaunch (
126+ workspaceService . object ,
127+ appShell . object ,
128+ pythonPathUpdaterService . object ,
129+ interpreterService . object ,
130+ processServiceFactory . object ,
131+ ) ;
132+ const result = await activatedEnvLaunch . selectIfLaunchedViaActivatedEnv ( ) ;
133+ expect ( result ) . to . be . equal ( undefined , 'Incorrect value' ) ;
134+ pythonPathUpdaterService . verifyAll ( ) ;
135+ } ) ;
136+
97137 test ( 'Updates interpreter path with the base conda prefix if activated and environment var is configured to not auto activate it' , async ( ) => {
98138 process . env . CONDA_PREFIX = condaPrefix ;
99139 process . env . CONDA_SHLVL = '1' ;
0 commit comments