@@ -248,7 +248,7 @@ suite('Python envs locator - Environments Reducer', () => {
248248 assert . deepEqual ( resolved , expected ) ;
249249 } ) ;
250250
251- test ( "If the reducer isn't able to resolve environment, return undefined " , async ( ) => {
251+ test ( "If the reducer isn't able to resolve environment, fall back to the wrapped locator " , async ( ) => {
252252 const env1 = createNamedEnv ( 'env' , '3.8' , PythonEnvKind . Conda , path . join ( 'path' , 'to' , 'exec' ) ) ;
253253 const env2 = createNamedEnv ( 'env2' , '2.7' , PythonEnvKind . System , path . join ( 'path' , 'to' , 'exec3' ) ) ;
254254 const env3 = createNamedEnv ( 'env' , '3.8.1b1' , PythonEnvKind . System , path . join ( 'path' , 'to' , 'exec' ) ) ;
@@ -257,20 +257,24 @@ suite('Python envs locator - Environments Reducer', () => {
257257 const env6 = createNamedEnv ( 'env' , '3.8.1' , PythonEnvKind . Unknown , path . join ( 'path' , 'to' , 'exec' ) ) ;
258258 const environmentsToBeIterated = [ env1 , env2 , env3 , env4 , env5 , env6 ] ; // env1 env3 env6 are same
259259
260- const env136 = createNamedEnv ( 'env' , '3.8.1b1' , PythonEnvKind . Conda , path . join ( 'path' , 'to' , 'exec' ) ) ;
260+ const filename1 = path . join ( 'resolved' , 'path' , 'to' , 'execNeverSeenBefore' ) ;
261+ const filename2 = path . join ( 'resolved' , 'path' , 'to' , 'execAlsoNeverSeenBefore' ) ;
262+ const expected = createNamedEnv ( 'resolvedEnv' , '3.8.1' , PythonEnvKind . Conda , filename1 ) ;
261263 const parentLocator = new SimpleLocator ( environmentsToBeIterated , {
262264 resolve : async ( e : PythonEnvInfo ) => {
263- if ( isEqual ( e , env136 ) ) {
264- return createNamedEnv ( 'resolvedEnv' , '3.8.1' , PythonEnvKind . Conda , 'resolved/path/to/exec' ) ;
265+ if ( e . executable . filename === expected . executable . filename ) {
266+ return expected ;
265267 }
266- throw new Error ( 'Incorrect environment sent to the resolve' ) ;
268+ return undefined ;
267269 } ,
268270 } ) ;
269271 const reducer = new PythonEnvsReducer ( parentLocator ) ;
270272
271- const expected = await reducer . resolveEnv ( path . join ( 'path' , 'to' , 'execNeverSeenBefore' ) ) ;
273+ const resolved1 = await reducer . resolveEnv ( filename1 ) ;
274+ const resolved2 = await reducer . resolveEnv ( filename2 ) ;
272275
273- assert . deepEqual ( expected , undefined ) ;
276+ assert . deepEqual ( resolved1 , expected ) ;
277+ assert . equal ( resolved2 , undefined ) ;
274278 } ) ;
275279 } ) ;
276280} ) ;
0 commit comments