diff --git a/src/client/common/process/pythonExecutionFactory.ts b/src/client/common/process/pythonExecutionFactory.ts index 6ed384381751..510da059ef9a 100644 --- a/src/client/common/process/pythonExecutionFactory.ts +++ b/src/client/common/process/pythonExecutionFactory.ts @@ -82,8 +82,8 @@ export class PythonExecutionFactory implements IPythonExecutionFactory { ); } } + pythonPath = this.configService.getSettings(options.resource).pythonPath; } - pythonPath = this.configService.getSettings(options.resource).pythonPath; const processService: IProcessService = await this.processServiceFactory.create(options.resource); processService.on('exec', this.logger.logProcess.bind(this.logger)); diff --git a/src/test/common/process/pythonExecutionFactory.unit.test.ts b/src/test/common/process/pythonExecutionFactory.unit.test.ts index bccda1f8c724..852afa046912 100644 --- a/src/test/common/process/pythonExecutionFactory.unit.test.ts +++ b/src/test/common/process/pythonExecutionFactory.unit.test.ts @@ -188,6 +188,23 @@ suite('Process - PythonExecutionFactory', () => { verify(pythonSettings.pythonPath).once(); }); + test('If interpreter is explicitly set, ensure we use it', async () => { + const pythonSettings = mock(PythonSettings); + when(processFactory.create(resource)).thenResolve(processService.object); + inDiscoveryExperimentStub.resolves(true); + when(activationHelper.getActivatedEnvironmentVariables(resource)).thenResolve({ x: '1' }); + reset(interpreterPathExpHelper); + when(interpreterPathExpHelper.get(anything())).thenReturn('python'); + when(autoSelection.autoSelectInterpreter(anything())).thenResolve(); + when(configService.getSettings(resource)).thenReturn(instance(pythonSettings)); + + const service = await factory.create({ resource, pythonPath: 'HELLO' }); + + expect(service).to.not.equal(undefined); + verify(pyenvs.isWindowsStoreInterpreter('HELLO')).once(); + verify(pythonSettings.pythonPath).never(); + }); + test('If no interpreter is explicitly set, ensure we autoselect before PythonExecutionService is created', async () => { const pythonSettings = mock(PythonSettings); when(processFactory.create(resource)).thenResolve(processService.object);