@@ -51,7 +51,7 @@ suite('Kernel Finder', () => {
51
51
specFile : path . join ( '1' , 'share' , 'jupyter' , 'kernels' , kernelName , 'kernel.json' )
52
52
} ;
53
53
// Change this to your actual JUPYTER_PATH value and see it appearing on the paths in the kernelFinder
54
- const JupyterPathEnvVar = '' ;
54
+ let JupyterPathEnvVar = '' ;
55
55
56
56
function setupFileSystem ( ) {
57
57
fileSystem
@@ -103,8 +103,12 @@ suite('Kernel Finder', () => {
103
103
let interpreter0Kernel : IJupyterKernelSpec ;
104
104
let interpreter1Kernel : IJupyterKernelSpec ;
105
105
let globalKernel : IJupyterKernelSpec ;
106
+ let jupyterPathKernelA : IJupyterKernelSpec ;
107
+ let jupyterPathKernelB : IJupyterKernelSpec ;
106
108
let loadError = false ;
107
109
setup ( ( ) => {
110
+ JupyterPathEnvVar = `Users/testuser/jupyterPathDirA${ path . delimiter } Users/testuser/jupyterPathDirB` ;
111
+
108
112
activeInterpreter = {
109
113
path : context . object . globalStoragePath ,
110
114
displayName : 'activeInterpreter' ,
@@ -191,6 +195,26 @@ suite('Kernel Finder', () => {
191
195
argv : [ '<python path>' , '-m' , 'ipykernel_launcher' , '-f' , '{connection_file}' ]
192
196
} ;
193
197
198
+ jupyterPathKernelA = {
199
+ name : 'jupyterPathKernelA' ,
200
+ language : 'python' ,
201
+ path : '<python path>' ,
202
+ display_name : 'Python 3' ,
203
+ metadata : { } ,
204
+ env : { } ,
205
+ argv : [ '<python path>' , '-m' , 'ipykernel_launcher' , '-f' , '{connection_file}' ]
206
+ } ;
207
+
208
+ jupyterPathKernelB = {
209
+ name : 'jupyterPathKernelB' ,
210
+ language : 'python' ,
211
+ path : '<python path>' ,
212
+ display_name : 'Python 3' ,
213
+ metadata : { } ,
214
+ env : { } ,
215
+ argv : [ '<python path>' , '-m' , 'ipykernel_launcher' , '-f' , '{connection_file}' ]
216
+ } ;
217
+
194
218
platformService . reset ( ) ;
195
219
platformService . setup ( ( ps ) => ps . isWindows ) . returns ( ( ) => false ) ;
196
220
platformService . setup ( ( ps ) => ps . isMac ) . returns ( ( ) => true ) ;
@@ -229,6 +253,7 @@ suite('Kernel Finder', () => {
229
253
. setup ( ( fs ) => fs . search ( typemoq . It . isAnyString ( ) , interpreter1Path , typemoq . It . isAny ( ) ) )
230
254
. returns ( ( ) => Promise . resolve ( [ path . join ( interpreter1Kernel . name , 'kernel.json' ) ] ) ) ;
231
255
256
+ // Global path setup
232
257
const globalPath = path . join ( 'usr' , 'share' , 'jupyter' , 'kernels' ) ;
233
258
const globalFullPath = path . join ( globalPath , globalKernel . name , 'kernel.json' ) ;
234
259
fileSystem
@@ -245,6 +270,26 @@ suite('Kernel Finder', () => {
245
270
. setup ( ( fs ) => fs . search ( typemoq . It . isAnyString ( ) , globalBPath , typemoq . It . isAny ( ) ) )
246
271
. returns ( ( ) => Promise . resolve ( [ ] ) ) ;
247
272
273
+ // Jupyter path setup
274
+ const jupyterPathKernelAPath = path . join ( 'Users' , 'testuser' , 'jupyterPathDirA' , 'kernels' ) ;
275
+ const jupyterPathKernelAFullPath = path . join (
276
+ jupyterPathKernelAPath ,
277
+ jupyterPathKernelA . name ,
278
+ 'kernel.json'
279
+ ) ;
280
+ const jupyterPathKernelBPath = path . join ( 'Users' , 'testuser' , 'jupyterPathDirB' , 'kernels' ) ;
281
+ const jupyterPathKernelBFullPath = path . join (
282
+ jupyterPathKernelBPath ,
283
+ jupyterPathKernelB . name ,
284
+ 'kernel.json'
285
+ ) ;
286
+ fileSystem
287
+ . setup ( ( fs ) => fs . search ( typemoq . It . isAnyString ( ) , jupyterPathKernelAPath , typemoq . It . isAny ( ) ) )
288
+ . returns ( ( ) => Promise . resolve ( [ path . join ( jupyterPathKernelA . name , 'kernel.json' ) ] ) ) ;
289
+ fileSystem
290
+ . setup ( ( fs ) => fs . search ( typemoq . It . isAnyString ( ) , jupyterPathKernelBPath , typemoq . It . isAny ( ) ) )
291
+ . returns ( ( ) => Promise . resolve ( [ path . join ( jupyterPathKernelB . name , 'kernel.json' ) ] ) ) ;
292
+
248
293
// Set the file system to return our kernelspec json
249
294
fileSystem
250
295
. setup ( ( fs ) => fs . readFile ( typemoq . It . isAnyString ( ) ) )
@@ -264,6 +309,10 @@ suite('Kernel Finder', () => {
264
309
return Promise . resolve ( JSON . stringify ( interpreter1Kernel ) ) ;
265
310
case globalFullPath :
266
311
return Promise . resolve ( JSON . stringify ( globalKernel ) ) ;
312
+ case jupyterPathKernelAFullPath :
313
+ return Promise . resolve ( JSON . stringify ( jupyterPathKernelA ) ) ;
314
+ case jupyterPathKernelBFullPath :
315
+ return Promise . resolve ( JSON . stringify ( jupyterPathKernelB ) ) ;
267
316
default :
268
317
return Promise . resolve ( '' ) ;
269
318
}
@@ -292,7 +341,9 @@ suite('Kernel Finder', () => {
292
341
expect ( specs [ 1 ] ) . to . deep . include ( activeKernelB ) ;
293
342
expect ( specs [ 2 ] ) . to . deep . include ( interpreter0Kernel ) ;
294
343
expect ( specs [ 3 ] ) . to . deep . include ( interpreter1Kernel ) ;
295
- expect ( specs [ 4 ] ) . to . deep . include ( globalKernel ) ;
344
+ expect ( specs [ 4 ] ) . to . deep . include ( jupyterPathKernelA ) ;
345
+ expect ( specs [ 5 ] ) . to . deep . include ( jupyterPathKernelB ) ;
346
+ expect ( specs [ 6 ] ) . to . deep . include ( globalKernel ) ;
296
347
fileSystem . reset ( ) ;
297
348
} ) ;
298
349
@@ -303,7 +354,9 @@ suite('Kernel Finder', () => {
303
354
expect ( specs [ 0 ] ) . to . deep . include ( activeKernelB ) ;
304
355
expect ( specs [ 1 ] ) . to . deep . include ( interpreter0Kernel ) ;
305
356
expect ( specs [ 2 ] ) . to . deep . include ( interpreter1Kernel ) ;
306
- expect ( specs [ 3 ] ) . to . deep . include ( globalKernel ) ;
357
+ expect ( specs [ 3 ] ) . to . deep . include ( jupyterPathKernelA ) ;
358
+ expect ( specs [ 4 ] ) . to . deep . include ( jupyterPathKernelB ) ;
359
+ expect ( specs [ 5 ] ) . to . deep . include ( globalKernel ) ;
307
360
fileSystem . reset ( ) ;
308
361
} ) ;
309
362
} ) ;
0 commit comments