Skip to content

Commit 2b8619f

Browse files
committed
fix: skip useEnvironmentsExtension check in test environments
The python.useEnvironmentsExtension setting is defined by ms-python.python which isn't installed during tests. Instead of polluting the python.* namespace by defining the setting ourselves, we check for test environment variables (VSC_PYTHON_SMOKE_TEST, VSC_PYTHON_E2E_TEST, VSC_PYTHON_INTEGRATION_TEST) and skip the setting check when running tests.
1 parent ddc501d commit 2b8619f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ import { registerPoetryFeatures } from './managers/poetry/main';
8787
import { registerPyenvFeatures } from './managers/pyenv/main';
8888

8989
export async function activate(context: ExtensionContext): Promise<PythonEnvironmentApi | undefined> {
90-
const useEnvironmentsExtension = getConfiguration('python').get<boolean>('useEnvironmentsExtension', true);
90+
// In smoke/e2e/integration tests, skip the useEnvironmentsExtension check since ms-python.python isn't installed
91+
const isTestEnvironment = process.env.VSC_PYTHON_SMOKE_TEST === '1' ||
92+
process.env.VSC_PYTHON_E2E_TEST === '1' ||
93+
process.env.VSC_PYTHON_INTEGRATION_TEST === '1';
94+
95+
const useEnvironmentsExtension = isTestEnvironment ||
96+
getConfiguration('python').get<boolean>('useEnvironmentsExtension', true);
9197
traceInfo(`Experiment Status: useEnvironmentsExtension setting set to ${useEnvironmentsExtension}`);
9298
if (!useEnvironmentsExtension) {
9399
traceWarn(

0 commit comments

Comments
 (0)