Skip to content

Commit b38ea75

Browse files
authored
Remove dependency on ts-mock-imports. (#18425)
1 parent df49596 commit b38ea75

File tree

6 files changed

+9
-33
lines changed

6 files changed

+9
-33
lines changed

news/3 Code Health/14757.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove dependency on `ts-mock-imports`.

package-lock.json

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,6 @@
20492049
"sinon": "^8.0.1",
20502050
"source-map-support": "^0.5.12",
20512051
"ts-loader": "^5.3.0",
2052-
"ts-mock-imports": "^1.3.0",
20532052
"ts-mockito": "^2.5.0",
20542053
"ts-node": "^8.3.0",
20552054
"tsconfig-paths-webpack-plugin": "^3.2.0",

src/test/pythonEnvironments/base/info/environmentInfoService.functional.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import * as assert from 'assert';
77
import * as sinon from 'sinon';
8-
import { ImportMock } from 'ts-mock-imports';
98
import { SemVer } from 'semver';
109
import { ExecutionResult } from '../../../../client/common/process/types';
1110
import { IDisposableRegistry } from '../../../../client/common/types';
@@ -42,9 +41,8 @@ suite('Environment Info Service', () => {
4241

4342
setup(() => {
4443
disposables = [];
45-
stubShellExec = ImportMock.mockFunction(
46-
ExternalDep,
47-
'shellExecute',
44+
stubShellExec = sinon.stub(ExternalDep, 'shellExecute');
45+
stubShellExec.returns(
4846
new Promise<ExecutionResult<string>>((resolve) => {
4947
resolve({
5048
stdout:

src/test/pythonEnvironments/base/locators/composite/envsResolver.unit.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { assert } from 'chai';
55
import { cloneDeep } from 'lodash';
66
import * as path from 'path';
77
import * as sinon from 'sinon';
8-
import { ImportMock } from 'ts-mock-imports';
98
import { EventEmitter, Uri } from 'vscode';
109
import { ExecutionResult } from '../../../../../client/common/process/types';
1110
import { IDisposableRegistry } from '../../../../../client/common/types';
@@ -92,9 +91,8 @@ suite('Python envs locator - Environments Resolver', () => {
9291
let stubShellExec: sinon.SinonStub;
9392
setup(() => {
9493
sinon.stub(platformApis, 'getOSType').callsFake(() => platformApis.OSType.Windows);
95-
stubShellExec = ImportMock.mockFunction(
96-
externalDependencies,
97-
'shellExecute',
94+
stubShellExec = sinon.stub(externalDependencies, 'shellExecute');
95+
stubShellExec.returns(
9896
new Promise<ExecutionResult<string>>((resolve) => {
9997
resolve({
10098
stdout:
@@ -243,9 +241,8 @@ suite('Python envs locator - Environments Resolver', () => {
243241
let stubShellExec: sinon.SinonStub;
244242
setup(() => {
245243
sinon.stub(platformApis, 'getOSType').callsFake(() => platformApis.OSType.Windows);
246-
stubShellExec = ImportMock.mockFunction(
247-
externalDependencies,
248-
'shellExecute',
244+
stubShellExec = sinon.stub(externalDependencies, 'shellExecute');
245+
stubShellExec.returns(
249246
new Promise<ExecutionResult<string>>((resolve) => {
250247
resolve({
251248
stdout:

src/test/pythonEnvironments/common/environmentManagers/simplevirtualenvs.unit.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as assert from 'assert';
55
import * as fsapi from 'fs-extra';
66
import * as path from 'path';
77
import * as sinon from 'sinon';
8-
import { ImportMock } from 'ts-mock-imports';
98
import * as platformUtils from '../../../../client/common/utils/platform';
109
import { PythonReleaseLevel, PythonVersion } from '../../../../client/pythonEnvironments/base/info';
1110
import * as fileUtils from '../../../../client/pythonEnvironments/common/externalDependencies';
@@ -25,11 +24,11 @@ suite('isVenvEnvironment Tests', () => {
2524
let fileExistsStub: sinon.SinonStub;
2625

2726
setup(() => {
28-
fileExistsStub = ImportMock.mockFunction(fileUtils, 'pathExists');
27+
fileExistsStub = sinon.stub(fileUtils, 'pathExists');
2928
});
3029

3130
teardown(() => {
32-
fileExistsStub.restore();
31+
sinon.restore();
3332
});
3433

3534
test('pyvenv.cfg does not exist', async () => {

0 commit comments

Comments
 (0)