@@ -194,6 +194,7 @@ suite('Python API Tests', () => {
194194
195195 suite ( 'getEnvironmentVariables' , ( ) => {
196196 test ( 'Should return environment variables from Python extension API' , async ( ) => {
197+ // eslint-disable-next-line @typescript-eslint/naming-convention
197198 const expectedVars = { PATH : '/usr/bin' , PYTHONPATH : '/usr/lib/python3' } ;
198199 mockPythonEnvApi . environments . getEnvironmentVariables . returns ( Promise . resolve ( expectedVars ) ) ;
199200
@@ -207,6 +208,7 @@ suite('Python API Tests', () => {
207208
208209 test ( 'Should get environment variables for specific resource' , async ( ) => {
209210 const resource = Uri . file ( '/workspace/file.py' ) ;
211+ // eslint-disable-next-line @typescript-eslint/naming-convention
210212 const expectedVars = { PATH : '/usr/bin' } ;
211213 mockPythonEnvApi . environments . getEnvironmentVariables . returns ( Promise . resolve ( expectedVars ) ) ;
212214
@@ -217,6 +219,19 @@ suite('Python API Tests', () => {
217219 expect ( result ) . to . deep . equal ( expectedVars ) ;
218220 sinon . assert . calledWith ( mockPythonEnvApi . environments . getEnvironmentVariables , resource ) ;
219221 } ) ;
222+
223+ test ( 'Should handle undefined resource and return workspace environment variables' , async ( ) => {
224+ // eslint-disable-next-line @typescript-eslint/naming-convention
225+ const expectedVars = { PATH : '/usr/bin' , PYTHONPATH : '/workspace/python' } ;
226+ mockPythonEnvApi . environments . getEnvironmentVariables . returns ( Promise . resolve ( expectedVars ) ) ;
227+
228+ sinon . stub ( PythonExtension , 'api' ) . resolves ( mockPythonEnvApi ) ;
229+
230+ const result = await pythonApi . getEnvironmentVariables ( undefined ) ;
231+
232+ expect ( result ) . to . deep . equal ( expectedVars ) ;
233+ sinon . assert . calledWith ( mockPythonEnvApi . environments . getEnvironmentVariables , undefined ) ;
234+ } ) ;
220235 } ) ;
221236
222237 suite ( 'resolveEnvironment' , ( ) => {
@@ -333,9 +348,12 @@ suite('Python API Tests', () => {
333348
334349 test ( 'Should quote path with spaces' , async ( ) => {
335350 const pythonPath = '/path with spaces/python3' ;
351+ const mockUri = {
352+ fsPath : pythonPath ,
353+ } ;
336354 const mockEnv : ResolvedEnvironment = {
337355 id : 'test-env' ,
338- executable : { uri : Uri . file ( pythonPath ) } ,
356+ executable : { uri : mockUri } ,
339357 } as ResolvedEnvironment ;
340358
341359 mockPythonEnvApi . environments . getActiveEnvironmentPath . returns ( { path : pythonPath } ) ;
0 commit comments