diff --git a/.vscode/launch.json b/.vscode/launch.json index 4dc107853fc6..1e983413c8d4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -127,6 +127,9 @@ "--extensionDevelopmentPath=${workspaceFolder}", "--extensionTestsPath=${workspaceFolder}/out/test" ], + "env": { + "VSC_PYTHON_CI_TEST_GREP": "" // Modify this to run a subset of the single workspace tests + }, "sourceMaps": true, "smartStep": true, "outFiles": ["${workspaceFolder}/out/**/*", "!${workspaceFolder}/**/node_modules**/*"], diff --git a/src/test/common/variables/envVarsProvider.multiroot.test.ts b/src/test/common/variables/envVarsProvider.multiroot.test.ts index e558bf8b1efc..3ba073d71474 100644 --- a/src/test/common/variables/envVarsProvider.multiroot.test.ts +++ b/src/test/common/variables/envVarsProvider.multiroot.test.ts @@ -4,7 +4,7 @@ import { expect, use } from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as path from 'path'; -import { anything, instance, mock, when } from 'ts-mockito'; +import { anything } from 'ts-mockito'; import { ConfigurationTarget, Disposable, Uri, workspace } from 'vscode'; import { WorkspaceService } from '../../../client/common/application/workspace'; import { PlatformService } from '../../../client/common/platform/platformService'; @@ -14,7 +14,6 @@ import { getSearchPathEnvVarNames } from '../../../client/common/utils/exec'; import { EnvironmentVariablesService } from '../../../client/common/variables/environment'; import { EnvironmentVariablesProvider } from '../../../client/common/variables/environmentVariablesProvider'; import { EnvironmentVariables } from '../../../client/common/variables/types'; -import { EnvironmentActivationService } from '../../../client/interpreter/activation/service'; import { IEnvironmentActivationService } from '../../../client/interpreter/activation/types'; import { IInterpreterAutoSelectionService } from '../../../client/interpreter/autoSelection/types'; import { clearPythonPathInWorkspaceFolder, isOs, OSType, updateSetting } from '../../common'; @@ -22,6 +21,7 @@ import { closeActiveWindows, initialize, initializeTest, IS_MULTI_ROOT_TEST } fr import { MockAutoSelectionService } from '../../mocks/autoSelector'; import { MockProcess } from '../../mocks/process'; import { UnitTestIocContainer } from '../../testing/serviceRegistry'; +import { createTypeMoq } from '../../mocks/helper'; use(chaiAsPromised.default); @@ -47,12 +47,21 @@ suite('Multiroot Environment Variables Provider', () => { ioc.registerProcessTypes(); ioc.registerInterpreterStorageTypes(); await ioc.registerMockInterpreterTypes(); - const mockEnvironmentActivationService = mock(EnvironmentActivationService); - when(mockEnvironmentActivationService.getActivatedEnvironmentVariables(anything())).thenResolve(); - ioc.serviceManager.rebindInstance( - IEnvironmentActivationService, - instance(mockEnvironmentActivationService), - ); + const mockEnvironmentActivationService = createTypeMoq(); + mockEnvironmentActivationService + .setup((m) => m.getActivatedEnvironmentVariables(anything())) + .returns(() => Promise.resolve({})); + if (ioc.serviceManager.tryGet(IEnvironmentActivationService)) { + ioc.serviceManager.rebindInstance( + IEnvironmentActivationService, + mockEnvironmentActivationService.object, + ); + } else { + ioc.serviceManager.addSingletonInstance( + IEnvironmentActivationService, + mockEnvironmentActivationService.object, + ); + } return initializeTest(); }); suiteTeardown(closeActiveWindows);