Skip to content

Commit ea98191

Browse files
committed
Fix tests
1 parent 5b8d878 commit ea98191

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/client/pythonEnvironments/nativeAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class NativePythonEnvironments implements IDiscoveryAPI, Disposable {
404404
traceLog(`Conda environment manager found at: ${native.executable}`);
405405
const settingPath = getCondaPathSetting();
406406
if (!this.condaPathAlreadySet) {
407-
if (settingPath === '') {
407+
if (settingPath === '' || settingPath === undefined) {
408408
if (foundOnPath(native.executable)) {
409409
setCondaBinary(native.executable);
410410
this.condaPathAlreadySet = native.executable;

src/test/pythonEnvironments/nativeAPI.unit.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
NativeEnvManagerInfo,
1414
NativePythonFinder,
1515
} from '../../client/pythonEnvironments/base/locators/common/nativePythonFinder';
16-
import { Architecture, isWindows } from '../../client/common/utils/platform';
16+
import { Architecture, getPathEnvVariable, isWindows } from '../../client/common/utils/platform';
1717
import { PythonEnvInfo, PythonEnvKind, PythonEnvType } from '../../client/pythonEnvironments/base/info';
1818
import { NativePythonEnvironmentKind } from '../../client/pythonEnvironments/base/locators/common/nativePythonUtils';
1919
import * as condaApi from '../../client/pythonEnvironments/common/environmentManagers/conda';
@@ -25,6 +25,8 @@ suite('Native Python API', () => {
2525
let api: IDiscoveryAPI;
2626
let mockFinder: typemoq.IMock<NativePythonFinder>;
2727
let setCondaBinaryStub: sinon.SinonStub;
28+
let getCondaPathSettingStub: sinon.SinonStub;
29+
let getCondaEnvDirsStub: sinon.SinonStub;
2830
let setPyEnvBinaryStub: sinon.SinonStub;
2931
let createPythonWatcherStub: sinon.SinonStub;
3032
let mockWatcher: typemoq.IMock<pw.PythonWatcher>;
@@ -136,6 +138,8 @@ suite('Native Python API', () => {
136138

137139
setup(() => {
138140
setCondaBinaryStub = sinon.stub(condaApi, 'setCondaBinary');
141+
getCondaEnvDirsStub = sinon.stub(condaApi, 'getCondaEnvDirs');
142+
getCondaPathSettingStub = sinon.stub(condaApi, 'getCondaPathSetting');
139143
setPyEnvBinaryStub = sinon.stub(pyenvApi, 'setPyEnvBinary');
140144
getWorkspaceFoldersStub = sinon.stub(ws, 'getWorkspaceFolders');
141145
getWorkspaceFoldersStub.returns([]);
@@ -294,9 +298,12 @@ suite('Native Python API', () => {
294298
});
295299

296300
test('Setting conda binary', async () => {
301+
getCondaPathSettingStub.returns(undefined);
302+
getCondaEnvDirsStub.resolves(undefined);
303+
const condaFakeDir = getPathEnvVariable()[0];
297304
const condaMgr: NativeEnvManagerInfo = {
298305
tool: 'Conda',
299-
executable: '/usr/bin/conda',
306+
executable: path.join(condaFakeDir, 'conda'),
300307
};
301308
mockFinder
302309
.setup((f) => f.refresh())

0 commit comments

Comments
 (0)