diff --git a/src/client/pythonEnvironments/discovery/locators/services/poetry.ts b/src/client/pythonEnvironments/discovery/locators/services/poetry.ts index 520958e71464..2f4128724877 100644 --- a/src/client/pythonEnvironments/discovery/locators/services/poetry.ts +++ b/src/client/pythonEnvironments/discovery/locators/services/poetry.ts @@ -69,9 +69,9 @@ async function isLocalPoetryEnvironment(interpreterPath: string): Promise=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/src/test/pythonEnvironments/discovery/locators/lowLevel/poetry.unit.test.ts b/src/test/pythonEnvironments/discovery/locators/lowLevel/poetry.unit.test.ts index 4b1f5a727a38..0edd3eacf772 100644 --- a/src/test/pythonEnvironments/discovery/locators/lowLevel/poetry.unit.test.ts +++ b/src/test/pythonEnvironments/discovery/locators/lowLevel/poetry.unit.test.ts @@ -15,7 +15,7 @@ import { TEST_LAYOUT_ROOT } from '../../../common/commonTestConstants'; const testPoetryDir = path.join(TEST_LAYOUT_ROOT, 'poetry'); const project1 = path.join(testPoetryDir, 'project1'); -const project2 = path.join(testPoetryDir, 'project2'); +const project4 = path.join(testPoetryDir, 'project4'); const project3 = path.join(testPoetryDir, 'project3'); suite('isPoetryEnvironment Tests', () => { @@ -54,17 +54,9 @@ suite('isPoetryEnvironment Tests', () => { shellExecute = sinon.stub(externalDependencies, 'shellExecute'); getPythonSetting = sinon.stub(externalDependencies, 'getPythonSetting'); getPythonSetting.returns('poetry'); - shellExecute.callsFake((command: string, options: ShellOptions) => { - // eslint-disable-next-line default-case - switch (command) { - case 'poetry env list --full-path': - return Promise.resolve>({ stdout: '' }); - case 'poetry env info -p': - if (options.cwd && externalDependencies.arePathsSame(options.cwd, project1)) { - return Promise.resolve>({ - stdout: `${path.join(project1, '.venv')} \n`, - }); - } + shellExecute.callsFake((command: string, _options: ShellOptions) => { + if (command === 'poetry env list --full-path') { + return Promise.resolve>({ stdout: '' }); } return Promise.reject(new Error('Command failed')); }); @@ -84,8 +76,8 @@ suite('isPoetryEnvironment Tests', () => { expect(result).to.equal(false); }); - test(`Return false if running poetry for project dir as cwd fails`, async () => { - const result = await isPoetryEnvironment(path.join(project2, '.venv', 'bin', 'python')); + test(`Return false if running poetry for project dir as cwd fails (pyproject.toml file is invalid)`, async () => { + const result = await isPoetryEnvironment(path.join(project4, '.venv', 'bin', 'python')); expect(result).to.equal(false); }); }); diff --git a/src/test/pythonEnvironments/discovery/locators/poetryLocator.unit.test.ts b/src/test/pythonEnvironments/discovery/locators/poetryLocator.unit.test.ts index 4de56504e7f4..d26feb28e5fb 100644 --- a/src/test/pythonEnvironments/discovery/locators/poetryLocator.unit.test.ts +++ b/src/test/pythonEnvironments/discovery/locators/poetryLocator.unit.test.ts @@ -75,13 +75,7 @@ suite('Poetry Locator', () => { locator = new PoetryLocator(project1); getOSTypeStub.returns(platformUtils.OSType.Windows); shellExecute.callsFake((command: string, options: ShellOptions) => { - if (command === 'poetry env info -p') { - if (options.cwd && externalDependencies.arePathsSame(options.cwd, project1)) { - return Promise.resolve>({ - stdout: `${path.join(project1, '.venv')} \n`, - }); - } - } else if (command === 'poetry env list --full-path') { + if (command === 'poetry env list --full-path') { if (options.cwd && externalDependencies.arePathsSame(options.cwd, project1)) { return Promise.resolve>({ stdout: `${path.join(testPoetryDir, 'poetry-tutorial-project-6hnqYwvD-py3.8')} \n @@ -214,14 +208,7 @@ suite('Poetry Locator', () => { locator = new PoetryLocator(project2); getOSTypeStub.returns(platformUtils.OSType.Linux); shellExecute.callsFake((command: string, options: ShellOptions) => { - // eslint-disable-next-line default-case - if (command === 'poetry env info -p') { - if (options.cwd && externalDependencies.arePathsSame(options.cwd, project2)) { - return Promise.resolve>({ - stdout: `${path.join(project2, '.venv')} \n`, - }); - } - } else if (command === 'poetry env list --full-path') { + if (command === 'poetry env list --full-path') { if (options.cwd && externalDependencies.arePathsSame(options.cwd, project2)) { return Promise.resolve>({ stdout: `${path.join(testPoetryDir, 'posix1project-9hvDnqYw-py3.4')} (Activated)\n