@@ -18,6 +18,7 @@ import { IInterpreterService } from '../../../../../client/interpreter/contracts
1818import { PythonEnvironment } from '../../../../../client/pythonEnvironments/info' ;
1919import * as workspaceApis from '../../../../../client/common/vscodeApis/workspaceApis' ;
2020import * as helper from '../../../../../client/debugger/extension/configuration/resolvers/helper' ;
21+ import * as extapi from '../../../../../client/envExt/api.internal' ;
2122
2223suite ( 'Debugging - Config Resolver' , ( ) => {
2324 class BaseResolver extends BaseConfigurationResolver < AttachRequestArguments | LaunchRequestArguments > {
@@ -70,6 +71,7 @@ suite('Debugging - Config Resolver', () => {
7071 let getWorkspaceFoldersStub : sinon . SinonStub ;
7172 let getWorkspaceFolderStub : sinon . SinonStub ;
7273 let getProgramStub : sinon . SinonStub ;
74+ let useEnvExtensionStub : sinon . SinonStub ;
7375
7476 setup ( ( ) => {
7577 configurationService = mock ( ConfigurationService ) ;
@@ -78,6 +80,7 @@ suite('Debugging - Config Resolver', () => {
7880 getWorkspaceFoldersStub = sinon . stub ( workspaceApis , 'getWorkspaceFolders' ) ;
7981 getWorkspaceFolderStub = sinon . stub ( workspaceApis , 'getWorkspaceFolder' ) ;
8082 getProgramStub = sinon . stub ( helper , 'getProgram' ) ;
83+ useEnvExtensionStub = sinon . stub ( extapi , 'useEnvExtension' ) . returns ( false ) ;
8184 } ) ;
8285 teardown ( ( ) => {
8386 sinon . restore ( ) ;
@@ -290,6 +293,7 @@ suite('Debugging - Config Resolver', () => {
290293 } ) ;
291294
292295 test ( 'uses one exact program lookup for command-valued pythonPath and python' , async ( ) => {
296+ useEnvExtensionStub . returns ( true ) ;
293297 const workspaceUri = Uri . file ( path . resolve ( 'workspace' ) ) ;
294298 const programPath = path . join ( workspaceUri . fsPath , 'script.py' ) ;
295299 const workspacePython = path . resolve ( 'workspace-env' , 'python' ) ;
@@ -318,6 +322,7 @@ suite('Debugging - Config Resolver', () => {
318322 } ) ;
319323
320324 test ( 'falls back to the workspace interpreter when exact program lookup has no environment' , async ( ) => {
325+ useEnvExtensionStub . returns ( true ) ;
321326 const workspaceUri = Uri . file ( path . resolve ( 'workspace' ) ) ;
322327 const programPath = path . join ( workspaceUri . fsPath , 'script.py' ) ;
323328 const workspacePython = path . resolve ( 'workspace-env' , 'python' ) ;
@@ -336,6 +341,7 @@ suite('Debugging - Config Resolver', () => {
336341 } ) ;
337342
338343 test ( 'resolves a named workspace-folder program before exact interpreter lookup' , async ( ) => {
344+ useEnvExtensionStub . returns ( true ) ;
339345 const launchWorkspaceUri = Uri . file ( path . resolve ( 'workspace-a' ) ) ;
340346 const programWorkspaceUri = Uri . file ( path . resolve ( 'workspace-b' ) ) ;
341347 const programPath = path . join ( programWorkspaceUri . fsPath , 'script.py' ) ;
@@ -360,6 +366,7 @@ suite('Debugging - Config Resolver', () => {
360366 } ) ;
361367
362368 test ( 'does not mark a program interpreter that matches the workspace interpreter' , async ( ) => {
369+ useEnvExtensionStub . returns ( true ) ;
363370 const workspaceUri = Uri . file ( path . resolve ( 'workspace' ) ) ;
364371 const programPath = path . join ( workspaceUri . fsPath , 'script.py' ) ;
365372 const pythonPath = path . resolve ( 'env' , 'python' ) ;
@@ -374,6 +381,28 @@ suite('Debugging - Config Resolver', () => {
374381 expect ( config ) . to . not . have . property ( '__pythonIsProgramInterpreter' ) ;
375382 } ) ;
376383
384+ test ( 'does not use the program interpreter when the environments extension is not in use' , async ( ) => {
385+ useEnvExtensionStub . returns ( false ) ;
386+ const workspaceUri = Uri . file ( path . resolve ( 'workspace-a' ) ) ;
387+ const programWorkspaceUri = Uri . file ( path . resolve ( 'workspace-b' ) ) ;
388+ const programPath = path . join ( programWorkspaceUri . fsPath , 'script.py' ) ;
389+ const workspacePython = path . resolve ( 'workspace-env' , 'python' ) ;
390+ const config = { program : programPath } ;
391+ when ( interpreterService . getActiveInterpreter ( anything ( ) , anything ( ) ) ) . thenResolve ( {
392+ path : path . resolve ( 'program-env' , 'python' ) ,
393+ } as PythonEnvironment ) ;
394+ when ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . thenResolve ( {
395+ path : workspacePython ,
396+ } as PythonEnvironment ) ;
397+
398+ await resolver . resolveAndUpdatePythonPath ( workspaceUri , config as LaunchRequestArguments ) ;
399+
400+ expect ( config ) . to . have . property ( 'python' , workspacePython ) ;
401+ expect ( config ) . to . not . have . property ( '__pythonIsProgramInterpreter' ) ;
402+ verify ( interpreterService . getActiveInterpreter ( anything ( ) , anything ( ) ) ) . never ( ) ;
403+ verify ( interpreterService . getActiveInterpreter ( anything ( ) ) ) . once ( ) ;
404+ } ) ;
405+
377406 const localHostTestMatrix : Record < string , boolean > = {
378407 localhost : true ,
379408 '127.0.0.1' : true ,
0 commit comments