22// Licensed under the MIT License.
33
44import * as assert from 'assert' ;
5+ import * as path from 'path' ;
56import * as sinon from 'sinon' ;
67import { ConfigurationChangeEvent , Uri , WorkspaceConfiguration , WorkspaceFolder } from 'vscode' ;
78import { PythonEnvironment , PythonEnvironmentApi , PythonProject } from '../../api' ;
@@ -223,8 +224,9 @@ suite('Interpreter Selection - Priority Chain', () => {
223224 } ) ;
224225
225226 test ( 'should resolve ${workspaceFolder} in defaultInterpreterPath before native resolution' , async ( ) => {
226- const workspaceUri = Uri . file ( '/test/workspace' ) ;
227- const expandedInterpreterPath = '/test/workspace/backend/.venv/bin/python' ;
227+ const workspaceUri = Uri . file ( path . resolve ( '/test/workspace' ) ) ;
228+ // resolveVariables does simple string substitution, so forward slashes in the setting remain
229+ const expandedInterpreterPath = workspaceUri . fsPath + '/backend/.venv/bin/python' ;
228230 const workspaceFolder = { name : 'workspace' , uri : workspaceUri } as WorkspaceFolder ;
229231
230232 sandbox . stub ( workspaceApis , 'getConfiguration' ) . returns ( createMockConfig ( [ ] ) as WorkspaceConfiguration ) ;
@@ -239,7 +241,7 @@ suite('Interpreter Selection - Priority Chain', () => {
239241 mockNativeFinder . resolve . resolves ( {
240242 executable : expandedInterpreterPath ,
241243 version : '3.11.0' ,
242- prefix : '/test/workspace/ backend/ .venv',
244+ prefix : path . join ( workspaceUri . fsPath , ' backend' , ' .venv') ,
243245 } ) ;
244246 mockApi . resolveEnvironment . resolves ( {
245247 ...mockVenvEnv ,
@@ -723,6 +725,7 @@ suite('Interpreter Selection - resolveGlobalEnvironmentByPriority', () => {
723725 test ( 'should use defaultInterpreterPath for global scope when configured' , async ( ) => {
724726 const userPyenvPath = '/Users/test/.pyenv/versions/3.13.7/bin/python' ;
725727
728+ sandbox . stub ( workspaceApis , 'getWorkspaceFolders' ) . returns ( [ ] ) ;
726729 sandbox . stub ( helpers , 'getUserConfiguredSetting' ) . callsFake ( ( section : string , key : string ) => {
727730 if ( section === 'python' && key === 'defaultInterpreterPath' ) {
728731 return userPyenvPath ;
@@ -754,6 +757,7 @@ suite('Interpreter Selection - resolveGlobalEnvironmentByPriority', () => {
754757 const userPyenvPath = '/Users/test/.pyenv/versions/3.13.7/bin/python' ;
755758 const resolvedHomebrewPath = '/opt/homebrew/bin/python3' ;
756759
760+ sandbox . stub ( workspaceApis , 'getWorkspaceFolders' ) . returns ( [ ] ) ;
757761 sandbox . stub ( helpers , 'getUserConfiguredSetting' ) . callsFake ( ( section : string , key : string ) => {
758762 if ( section === 'python' && key === 'defaultInterpreterPath' ) {
759763 return userPyenvPath ;
0 commit comments