Skip to content

Commit f133230

Browse files
fix kernel finder tests (#11592)
1 parent d56a658 commit f133230

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/test/datascience/kernelFinder.unit.test.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,17 @@ suite('Kernel Finder', () => {
183183
argv: ['<python path>', '-m', 'ipykernel_launcher', '-f', '{connection_file}']
184184
};
185185

186+
platformService.reset();
187+
platformService.setup((ps) => ps.isWindows).returns(() => false);
188+
platformService.setup((ps) => ps.isMac).returns(() => true);
189+
186190
workspaceService = mock<IWorkspaceService>();
187191
when(workspaceService.getWorkspaceFolderIdentifier(anything(), resource.fsPath)).thenReturn(
188192
resource.fsPath
189193
);
190194

191195
// Setup file system
192-
const activePath = 'active/share/jupyter/kernels';
196+
const activePath = path.join('active', 'share', 'jupyter', 'kernels');
193197
const activePathA = path.join(activePath, activeKernelA.name, 'kernel.json');
194198
const activePathB = path.join(activePath, activeKernelB.name, 'kernel.json');
195199
fileSystem
@@ -206,9 +210,9 @@ suite('Kernel Finder', () => {
206210
path.join(activeKernelB.name, 'kernel.json')
207211
])
208212
);
209-
const interpreter0Path = 'Interpreter0/share/jupyter/kernels';
213+
const interpreter0Path = path.join('Interpreter0', 'share', 'jupyter', 'kernels');
210214
const interpreter0FullPath = path.join(interpreter0Path, interpreter0Kernel.name, 'kernel.json');
211-
const interpreter1Path = 'Interpreter1/share/jupyter/kernels';
215+
const interpreter1Path = path.join('Interpreter1', 'share', 'jupyter', 'kernels');
212216
const interpreter1FullPath = path.join(interpreter1Path, interpreter1Kernel.name, 'kernel.json');
213217
fileSystem
214218
.setup((fs) => fs.search(typemoq.It.isAnyString(), interpreter0Path))
@@ -217,12 +221,22 @@ suite('Kernel Finder', () => {
217221
.setup((fs) => fs.search(typemoq.It.isAnyString(), interpreter1Path))
218222
.returns(() => Promise.resolve([path.join(interpreter1Kernel.name, 'kernel.json')]));
219223

220-
const globalPath = 'AppData/Roaming/jupyter/kernels';
224+
const globalPath = path.join('usr', 'share', 'jupyter', 'kernels');
221225
const globalFullPath = path.join(globalPath, globalKernel.name, 'kernel.json');
222226
fileSystem
223227
.setup((fs) => fs.search(typemoq.It.isAnyString(), globalPath))
224228
.returns(() => Promise.resolve([path.join(globalKernel.name, 'kernel.json')]));
225229

230+
// Empty global paths
231+
const globalAPath = path.join('usr', 'local', 'share', 'jupyter', 'kernels');
232+
fileSystem
233+
.setup((fs) => fs.search(typemoq.It.isAnyString(), globalAPath))
234+
.returns(() => Promise.resolve([]));
235+
const globalBPath = path.join('Library', 'Jupyter', 'kernels');
236+
fileSystem
237+
.setup((fs) => fs.search(typemoq.It.isAnyString(), globalBPath))
238+
.returns(() => Promise.resolve([]));
239+
226240
// Set the file system to return our kernelspec json
227241
fileSystem
228242
.setup((fs) => fs.readFile(typemoq.It.isAnyString()))

0 commit comments

Comments
 (0)