|
40 | 40 | import * as assert from 'assert'; |
41 | 41 | import * as vscode from 'vscode'; |
42 | 42 | import { Package, PythonEnvironment, PythonEnvironmentApi } from '../../api'; |
| 43 | +import { CONDA_MANAGER_ID, PYTHON_EXTENSION_ID, VENV_MANAGER_ID } from '../../common/constants'; |
43 | 44 | import { normalizePackageName } from '../../managers/builtin/utils'; |
44 | 45 | import { ENVS_EXTENSION_ID } from '../constants'; |
45 | 46 | import { waitForCondition } from '../testUtils'; |
@@ -176,21 +177,23 @@ suite('Integration: Package Manager Roundtrip', function () { |
176 | 177 |
|
177 | 178 | /** |
178 | 179 | * Picks one representative environment per package manager, grouped by managerId. |
179 | | - * Prefers virtual-environment-like envs, which are safe to install into. |
| 180 | + * Only returns isolated environments that are safe for an install/uninstall test. |
180 | 181 | */ |
181 | 182 | async function getEnvironmentsByManager(): Promise<Map<string, PythonEnvironment>> { |
182 | 183 | const environments = await api.getEnvironments('all'); |
183 | 184 | const byManager = new Map<string, PythonEnvironment>(); |
184 | | - |
185 | | - const looksModifiable = (env: PythonEnvironment): boolean => |
186 | | - env.displayName.includes('venv') || |
187 | | - env.displayName.includes('.venv') || |
188 | | - env.envId.managerId.includes('venv'); |
| 185 | + const isolatedManagerIds = new Set([ |
| 186 | + VENV_MANAGER_ID, |
| 187 | + `${PYTHON_EXTENSION_ID}:pipenv`, |
| 188 | + `${PYTHON_EXTENSION_ID}:poetry`, |
| 189 | + ]); |
189 | 190 |
|
190 | 191 | for (const env of environments) { |
191 | 192 | const managerId = env.envId.managerId; |
192 | | - const current = byManager.get(managerId); |
193 | | - if (!current || (looksModifiable(env) && !looksModifiable(current))) { |
| 193 | + const isSafeToModify = |
| 194 | + isolatedManagerIds.has(managerId) || |
| 195 | + (managerId === CONDA_MANAGER_ID && env.name.toLowerCase() !== 'base'); |
| 196 | + if (isSafeToModify && !byManager.has(managerId)) { |
194 | 197 | byManager.set(managerId, env); |
195 | 198 | } |
196 | 199 | } |
|
0 commit comments