@@ -29,7 +29,8 @@ suite('Activated Env Launch', async () => {
29
29
let activatedEnvLaunch : ActivatedEnvironmentLaunch ;
30
30
let _promptIfApplicable : sinon . SinonStub ;
31
31
32
- suite ( 'Method getPrefixOfSelectedActivatedEnv()' , ( ) => {
32
+ suite ( 'Method selectIfLaunchedViaActivatedEnv()' , ( ) => {
33
+ const oldVSCodeCLI = process . env . VSCODE_CLI ;
33
34
const oldCondaPrefix = process . env . CONDA_PREFIX ;
34
35
const oldCondaShlvl = process . env . CONDA_SHLVL ;
35
36
const oldVirtualEnv = process . env . VIRTUAL_ENV ;
@@ -41,6 +42,7 @@ suite('Activated Env Launch', async () => {
41
42
processServiceFactory = TypeMoq . Mock . ofType < IProcessServiceFactory > ( ) ;
42
43
_promptIfApplicable = sinon . stub ( ActivatedEnvironmentLaunch . prototype , '_promptIfApplicable' ) ;
43
44
_promptIfApplicable . returns ( Promise . resolve ( ) ) ;
45
+ process . env . VSCODE_CLI = '1' ;
44
46
} ) ;
45
47
46
48
teardown ( ( ) => {
@@ -59,6 +61,11 @@ suite('Activated Env Launch', async () => {
59
61
} else {
60
62
delete process . env . VIRTUAL_ENV ;
61
63
}
64
+ if ( oldVSCodeCLI ) {
65
+ process . env . VSCODE_CLI = oldVSCodeCLI ;
66
+ } else {
67
+ delete process . env . VSCODE_CLI ;
68
+ }
62
69
sinon . restore ( ) ;
63
70
} ) ;
64
71
@@ -94,6 +101,39 @@ suite('Activated Env Launch', async () => {
94
101
pythonPathUpdaterService . verifyAll ( ) ;
95
102
} ) ;
96
103
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
+
97
137
test ( 'Updates interpreter path with the base conda prefix if activated and environment var is configured to not auto activate it' , async ( ) => {
98
138
process . env . CONDA_PREFIX = condaPrefix ;
99
139
process . env . CONDA_SHLVL = '1' ;
0 commit comments