Skip to content

Commit 027055a

Browse files
author
Kartik Raj
committed
Add smoke tests using real poetry for discovery
1 parent 865136d commit 027055a

File tree

7 files changed

+81
-1
lines changed

7 files changed

+81
-1
lines changed

.github/workflows/insiders.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ jobs:
174174
python -m pip install pipenv
175175
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
176176
177+
- name: Prepare poetry for venv tests
178+
env:
179+
TEST_FILES_SUFFIX: testvirtualenvs
180+
shell: pwsh
181+
if: matrix.test-suite == 'venv'
182+
run: |
183+
python -m pip install poetry
184+
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
185+
poetry env use python
186+
177187
- name: Prepare virtualenv for venv tests
178188
env:
179189
TEST_FILES_SUFFIX: testvirtualenvs

.github/workflows/nightly-coverage.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ jobs:
6767
python -m pip install pipenv
6868
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
6969
70+
- name: Prepare poetry for venv tests
71+
env:
72+
TEST_FILES_SUFFIX: testvirtualenvs
73+
shell: pwsh
74+
if: matrix.test-suite == 'venv'
75+
run: |
76+
python -m pip install poetry
77+
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
78+
poetry env use python
79+
7080
- name: Prepare virtualenv for venv tests
7181
env:
7282
TEST_FILES_SUFFIX: testvirtualenvs

.github/workflows/pr-check.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ jobs:
177177
python -m pip install pipenv
178178
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
179179
180+
- name: Prepare poetry for venv tests
181+
env:
182+
TEST_FILES_SUFFIX: testvirtualenvs
183+
shell: pwsh
184+
if: matrix.test-suite == 'venv'
185+
run: |
186+
python -m pip install poetry
187+
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
188+
poetry env use python
189+
180190
- name: Prepare virtualenv for venv tests
181191
env:
182192
TEST_FILES_SUFFIX: testvirtualenvs
@@ -485,6 +495,15 @@ jobs:
485495
python -m pip install pipenv
486496
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
487497
498+
- name: Prepare poetry for venv tests
499+
env:
500+
TEST_FILES_SUFFIX: testvirtualenvs
501+
shell: pwsh
502+
run: |
503+
python -m pip install poetry
504+
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
505+
poetry env use python
506+
488507
- name: Prepare virtualenv for venv tests
489508
env:
490509
TEST_FILES_SUFFIX: testvirtualenvs

.github/workflows/pr-file-check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
prereq-pattern: src/**/*.ts
4545
file-pattern: |
4646
src/**/*.test.ts
47+
src/**/*.testvirtualenvs.ts
4748
.github/test_plan.md
4849
skip-label: 'skip tests'
4950
failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)'

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ jobs:
170170
python -m pip install pipenv
171171
python -m pipenv run python ./build/ci/addEnvPath.py ${{env.PYTHON_VIRTUAL_ENVS_LOCATION}} pipenvPath
172172
173+
- name: Prepare poetry for venv tests
174+
env:
175+
TEST_FILES_SUFFIX: testvirtualenvs
176+
shell: pwsh
177+
if: matrix.test-suite == 'venv'
178+
run: |
179+
python -m pip install poetry
180+
Move-Item -Path ".\build\ci\pyproject.toml" -Destination .
181+
poetry env use python
182+
173183
- name: Prepare virtualenv for venv tests
174184
env:
175185
TEST_FILES_SUFFIX: testvirtualenvs

build/ci/pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[tool.poetry]
2+
name = "poetry-tutorial-project"
3+
version = "0.1.0"
4+
description = ""
5+
authors = [""]
6+
7+
[tool.poetry.dependencies]
8+
python = "*"

src/test/pythonEnvironments/discovery/locators/poetryLocator.testvirtualenvs.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
import { expect } from 'chai';
45
import * as path from 'path';
56
import * as sinon from 'sinon';
67
import { ExecutionResult, ShellOptions } from '../../../../client/common/process/types';
78
import { PythonEnvKind } from '../../../../client/pythonEnvironments/base/info';
9+
import { ILocator } from '../../../../client/pythonEnvironments/base/locator';
10+
import { getEnvs } from '../../../../client/pythonEnvironments/base/locatorUtils';
811
import * as externalDependencies from '../../../../client/pythonEnvironments/common/externalDependencies';
912
import { PoetryLocator } from '../../../../client/pythonEnvironments/discovery/locators/services/poetryLocator';
13+
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants';
1014
import { TEST_LAYOUT_ROOT } from '../../common/commonTestConstants';
1115
import { testLocatorWatcher } from './watcherTestUtils';
1216

13-
suite('Poetry Locator', async () => {
17+
suite('Poetry Watcher', async () => {
1418
let shellExecute: sinon.SinonStub;
1519
const testPoetryDir = path.join(TEST_LAYOUT_ROOT, 'poetry');
1620
const project1 = path.join(testPoetryDir, 'project1');
@@ -38,3 +42,21 @@ suite('Poetry Locator', async () => {
3842

3943
suiteTeardown(() => sinon.restore());
4044
});
45+
46+
suite('Poetry Locator', async function () {
47+
let locator: ILocator;
48+
suiteSetup(async function () {
49+
if (process.env.CI_PYTHON_VERSION && process.env.CI_PYTHON_VERSION.startsWith('2.')) {
50+
// Poetry is soon to be deprecated for Python2.7, and tests do not pass
51+
// as it is with pip installation of poetry, hence skip.
52+
this.skip();
53+
}
54+
locator = new PoetryLocator(path.join(EXTENSION_ROOT_DIR_FOR_TESTS));
55+
});
56+
57+
test('Discovers existing poetry environments', async () => {
58+
const items = await getEnvs(locator.iterEnvs());
59+
const isLocated = items.some((item) => item.kind === PythonEnvKind.Poetry && item.name.startsWith('poetry-tutorial-project'));
60+
expect(isLocated).to.equal(true);
61+
});
62+
});

0 commit comments

Comments
 (0)