@@ -158,7 +158,7 @@ suite('Debugging - Config Resolver', () => {
158
158
test ( 'Do nothing if debug configuration is undefined' , async ( ) => {
159
159
await resolver . resolveAndUpdatePythonPath ( undefined , ( undefined as unknown ) as LaunchRequestArguments ) ;
160
160
} ) ;
161
- test ( 'pythonPath in debug config must point to pythonPath in settings if pythonPath in config is not set' , async ( ) => {
161
+ test ( 'python in debug config must point to pythonPath in settings if pythonPath in config is not set' , async ( ) => {
162
162
const config = { } ;
163
163
const pythonPath = path . join ( '1' , '2' , '3' ) ;
164
164
@@ -168,11 +168,11 @@ suite('Debugging - Config Resolver', () => {
168
168
169
169
await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
170
170
171
- expect ( config ) . to . have . property ( 'pythonPath ' , pythonPath ) ;
171
+ expect ( config ) . to . have . property ( 'python ' , pythonPath ) ;
172
172
} ) ;
173
- test ( 'pythonPath in debug config must point to pythonPath in settings if pythonPath in config is ${command:python.interpreterPath}' , async ( ) => {
173
+ test ( 'python in debug config must point to pythonPath in settings if pythonPath in config is ${command:python.interpreterPath}' , async ( ) => {
174
174
const config = {
175
- pythonPath : '${command:python.interpreterPath}' ,
175
+ python : '${command:python.interpreterPath}' ,
176
176
} ;
177
177
const pythonPath = path . join ( '1' , '2' , '3' ) ;
178
178
@@ -182,8 +182,113 @@ suite('Debugging - Config Resolver', () => {
182
182
183
183
await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
184
184
185
- expect ( config . pythonPath ) . to . equal ( pythonPath ) ;
185
+ expect ( config . python ) . to . equal ( pythonPath ) ;
186
186
} ) ;
187
+
188
+ test ( 'config should only contain python and not pythonPath after resolving' , async ( ) => {
189
+ const config = { pythonPath : '${command:python.interpreterPath}' , python : '${command:python.interpreterPath}' } ;
190
+ const pythonPath = path . join ( '1' , '2' , '3' ) ;
191
+
192
+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( {
193
+ path : pythonPath ,
194
+ } as PythonEnvironment ) ;
195
+
196
+ await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
197
+ expect ( config ) . to . not . have . property ( 'pythonPath' ) ;
198
+ expect ( config ) . to . have . property ( 'python' , pythonPath ) ;
199
+ } ) ;
200
+
201
+ test ( 'config should convert pythonPath to python, only if python is not set' , async ( ) => {
202
+ const config = { pythonPath : '${command:python.interpreterPath}' , python : undefined } ;
203
+ const pythonPath = path . join ( '1' , '2' , '3' ) ;
204
+
205
+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( {
206
+ path : pythonPath ,
207
+ } as PythonEnvironment ) ;
208
+
209
+ await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
210
+ expect ( config ) . to . not . have . property ( 'pythonPath' ) ;
211
+ expect ( config ) . to . have . property ( 'python' , pythonPath ) ;
212
+ } ) ;
213
+
214
+ test ( 'config should not change python if python is different than pythonPath' , async ( ) => {
215
+ const expected = path . join ( '1' , '2' , '4' ) ;
216
+ const config = { pythonPath : '${command:python.interpreterPath}' , python : expected } ;
217
+ const pythonPath = path . join ( '1' , '2' , '3' ) ;
218
+
219
+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( {
220
+ path : pythonPath ,
221
+ } as PythonEnvironment ) ;
222
+
223
+ await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
224
+ expect ( config ) . to . not . have . property ( 'pythonPath' ) ;
225
+ expect ( config ) . to . have . property ( 'python' , expected ) ;
226
+ } ) ;
227
+
228
+ test ( 'config should get python from interpreter service is nothing is set' , async ( ) => {
229
+ const config = { } ;
230
+ const pythonPath = path . join ( '1' , '2' , '3' ) ;
231
+
232
+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( {
233
+ path : pythonPath ,
234
+ } as PythonEnvironment ) ;
235
+
236
+ await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
237
+ expect ( config ) . to . not . have . property ( 'pythonPath' ) ;
238
+ expect ( config ) . to . have . property ( 'python' , pythonPath ) ;
239
+ } ) ;
240
+
241
+ test ( 'config should contain debugAdapterPython and debugLauncherPython' , async ( ) => {
242
+ const config = { } ;
243
+ const pythonPath = path . join ( '1' , '2' , '3' ) ;
244
+
245
+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( {
246
+ path : pythonPath ,
247
+ } as PythonEnvironment ) ;
248
+
249
+ await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
250
+ expect ( config ) . to . not . have . property ( 'pythonPath' ) ;
251
+ expect ( config ) . to . have . property ( 'python' , pythonPath ) ;
252
+ expect ( config ) . to . have . property ( 'debugAdapterPython' , pythonPath ) ;
253
+ expect ( config ) . to . have . property ( 'debugLauncherPython' , pythonPath ) ;
254
+ } ) ;
255
+
256
+ test ( 'config should not change debugAdapterPython and debugLauncherPython if already set' , async ( ) => {
257
+ const debugAdapterPythonPath = path . join ( '1' , '2' , '4' ) ;
258
+ const debugLauncherPythonPath = path . join ( '1' , '2' , '5' ) ;
259
+
260
+ const config = { debugAdapterPython : debugAdapterPythonPath , debugLauncherPython : debugLauncherPythonPath } ;
261
+ const pythonPath = path . join ( '1' , '2' , '3' ) ;
262
+
263
+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( {
264
+ path : pythonPath ,
265
+ } as PythonEnvironment ) ;
266
+
267
+ await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
268
+ expect ( config ) . to . not . have . property ( 'pythonPath' ) ;
269
+ expect ( config ) . to . have . property ( 'python' , pythonPath ) ;
270
+ expect ( config ) . to . have . property ( 'debugAdapterPython' , debugAdapterPythonPath ) ;
271
+ expect ( config ) . to . have . property ( 'debugLauncherPython' , debugLauncherPythonPath ) ;
272
+ } ) ;
273
+
274
+ test ( 'config should not resolve debugAdapterPython and debugLauncherPython' , async ( ) => {
275
+ const config = {
276
+ debugAdapterPython : '${command:python.interpreterPath}' ,
277
+ debugLauncherPython : '${command:python.interpreterPath}' ,
278
+ } ;
279
+ const pythonPath = path . join ( '1' , '2' , '3' ) ;
280
+
281
+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( {
282
+ path : pythonPath ,
283
+ } as PythonEnvironment ) ;
284
+
285
+ await resolver . resolveAndUpdatePythonPath ( undefined , config as LaunchRequestArguments ) ;
286
+ expect ( config ) . to . not . have . property ( 'pythonPath' ) ;
287
+ expect ( config ) . to . have . property ( 'python' , pythonPath ) ;
288
+ expect ( config ) . to . have . property ( 'debugAdapterPython' , pythonPath ) ;
289
+ expect ( config ) . to . have . property ( 'debugLauncherPython' , pythonPath ) ;
290
+ } ) ;
291
+
187
292
const localHostTestMatrix : Record < string , boolean > = {
188
293
localhost : true ,
189
294
'127.0.0.1' : true ,
0 commit comments