Skip to content

Commit

Permalink
Fix python.poetryPath setting for installer on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Mar 18, 2021
1 parent 6955f5a commit a6e8287
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/9672.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `python.poetryPath` setting for installer on Windows.
2 changes: 1 addition & 1 deletion src/client/common/installer/poetryInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class PoetryInstaller extends ModuleInstaller {
try {
const processService = await this.processFactory.create(workfolder);
const execPath = this.configurationService.getSettings(workfolder).poetryPath;
const result = await processService.exec(execPath, ['list'], { cwd: workfolder.fsPath });
const result = await processService.shellExec(`${execPath} env list`, { cwd: workfolder.fsPath });
return result && (result.stderr || '').trim().length === 0;
} catch (error) {
traceError(`${poetryFile} exists but Poetry not found`, error);
Expand Down
11 changes: 7 additions & 4 deletions src/test/common/installer/poetryInstaller.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ suite('Module Installer - Poetry', () => {
when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 });
when(fileSystem.fileExists(anything())).thenResolve(true);
when(processServiceFactory.create(anything())).thenResolve(instance(processService));
when(processService.exec(anything(), anything(), anything())).thenResolve({ stderr: 'Kaboom', stdout: '' });
when(processService.shellExec(anything(), anything())).thenResolve({ stderr: 'Kaboom', stdout: '' });

const supported = await poetryInstaller.isSupported(Uri.file(__filename));

Expand All @@ -105,7 +105,7 @@ suite('Module Installer - Poetry', () => {
when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 });
when(fileSystem.fileExists(anything())).thenResolve(true);
when(processServiceFactory.create(anything())).thenResolve(instance(processService));
when(processService.exec(anything(), anything(), anything())).thenReject(new Error('Kaboom'));
when(processService.shellExec(anything(), anything())).thenReject(new Error('Kaboom'));

const supported = await poetryInstaller.isSupported(Uri.file(__filename));

Expand All @@ -121,7 +121,7 @@ suite('Module Installer - Poetry', () => {
when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 });
when(fileSystem.fileExists(anything())).thenResolve(true);
when(processServiceFactory.create(uri)).thenResolve(instance(processService));
when(processService.exec('poetry path', anything(), anything())).thenResolve({ stderr: '', stdout: '' });
when(processService.shellExec('poetry path', anything())).thenResolve({ stderr: '', stdout: '' });

const supported = await poetryInstaller.isSupported(Uri.file(__filename));

Expand All @@ -147,6 +147,9 @@ suite('Module Installer - Poetry', () => {

const info = await poetryInstaller.getExecutionInfo('black', uri);

assert.deepEqual(info, { args: ['add', '--dev', 'black', '--allow-prereleases'], execPath: 'poetry path' });
assert.deepEqual(info, {
args: ['add', '--dev', 'black', '--allow-prereleases'],
execPath: 'poetry path',
});
});
});

0 comments on commit a6e8287

Please sign in to comment.