Skip to content

Commit cec4929

Browse files
committed
rebased and fixed
1 parent 5d749eb commit cec4929

File tree

5 files changed

+4
-85
lines changed

5 files changed

+4
-85
lines changed

src/extension/common/application/commands/reportIssueCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import * as fs from 'fs-extra';
77
import * as path from 'path';
88
import { executeCommand } from '../../vscodeapi';
9-
import { getActiveEnvironmentPath, resolveEnvironment } from '../../python';
109
import { EXTENSION_ROOT_DIR } from '../../constants';
1110
import { sendTelemetryEvent } from '../../../telemetry';
1211
import { EventName } from '../../../telemetry/constants';
1312
import { PythonEnvironment } from '../../../envExtApi';
13+
import { getActiveEnvironmentPath, resolveEnvironment } from '../../python';
1414

1515
/**
1616
* Allows the user to report an issue related to the Python Debugger extension using our template.

src/extension/common/python.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/* eslint-disable @typescript-eslint/naming-convention */
55
import { Environment, EnvironmentPath, ResolvedEnvironment, Resource } from '@vscode/python-extension';
6-
import { commands, EventEmitter, extensions, Uri, Event, Disposable } from 'vscode';
6+
import { commands, EventEmitter, extensions, Uri, Event, Disposable, Extension } from 'vscode';
77
import { traceError, traceLog, traceWarn } from './log/logging';
88
import { PythonEnvironment, PythonEnvironmentApi, PythonEnvsExtension } from '../envExtApi';
99
import {

src/extension/debugger/adapter/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import { executeCommand, showErrorMessage } from '../../common/vscodeapi';
1919
import { traceLog, traceVerbose } from '../../common/log/logging';
2020
import { EventName } from '../../telemetry/constants';
2121
import { sendTelemetryEvent } from '../../telemetry';
22-
import { getInterpreterDetails, resolveEnvironment, runPythonExtensionCommand } from '../../common/python';
2322
import { Commands, EXTENSION_ROOT_DIR } from '../../common/constants';
2423
import { Common, DebugConfigStrings, Interpreters } from '../../common/utils/localize';
2524
import { IPersistentStateFactory } from '../../common/types';
2625
import { fileToCommandArgumentForPythonExt } from '../../common/stringUtils';
2726
import { PythonEnvironment } from '../../envExtApi';
27+
import { resolveEnvironment, getInterpreterDetails, runPythonExtensionCommand } from '../../common/python';
2828

2929
// persistent state names, exported to make use of in testing
3030
export enum debugStateKeys {

src/test/unittest/common/python.unit.test.ts

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -415,82 +415,6 @@ suite('Python API Tests', () => {
415415
});
416416
});
417417

418-
suite('hasInterpreters', () => {
419-
test('Should return true when interpreters are available initially', async () => {
420-
mockPythonEnvApi.environments.known = [{ id: 'env1', path: '/usr/bin/python3' } as Environment];
421-
sinon.stub(PythonExtension, 'api').resolves(mockPythonEnvApi);
422-
423-
const result = await pythonApi.hasInterpreters();
424-
425-
expect(result).to.be.true;
426-
});
427-
428-
test('Should return false when no interpreters are available', async () => {
429-
mockPythonEnvApi.environments.known = [];
430-
mockPythonEnvApi.environments.refreshEnvironments.resolves();
431-
sinon.stub(PythonExtension, 'api').resolves(mockPythonEnvApi);
432-
433-
const result = await pythonApi.hasInterpreters();
434-
435-
expect(result).to.be.false;
436-
});
437-
438-
test('Should wait for environments to be added after refresh', async () => {
439-
mockPythonEnvApi.environments.known = [];
440-
let onDidChangeCallback: any;
441-
mockPythonEnvApi.environments.onDidChangeEnvironments = (callback: any) => {
442-
onDidChangeCallback = callback;
443-
return { dispose: sinon.stub() };
444-
};
445-
mockPythonEnvApi.environments.refreshEnvironments = async () => {
446-
// Simulate environments being added
447-
mockPythonEnvApi.environments.known = [{ id: 'env1', path: '/usr/bin/python3' } as Environment];
448-
if (onDidChangeCallback) {
449-
onDidChangeCallback();
450-
}
451-
};
452-
453-
sinon.stub(PythonExtension, 'api').resolves(mockPythonEnvApi);
454-
455-
const result = await pythonApi.hasInterpreters();
456-
457-
expect(result).to.be.true;
458-
});
459-
});
460-
461-
suite('getInterpreters', () => {
462-
test('Should return list of known interpreters', async () => {
463-
const expectedEnvs: readonly Environment[] = [
464-
{ id: 'env1', path: '/usr/bin/python3' } as Environment,
465-
{ id: 'env2', path: '/usr/bin/python2' } as Environment,
466-
];
467-
mockPythonEnvApi.environments.known = expectedEnvs;
468-
sinon.stub(PythonExtension, 'api').resolves(mockPythonEnvApi);
469-
470-
const result = await pythonApi.getInterpreters();
471-
472-
expect(result).to.deep.equal(expectedEnvs);
473-
});
474-
475-
test('Should return empty array when no interpreters are available', async () => {
476-
mockPythonEnvApi.environments.known = [];
477-
sinon.stub(PythonExtension, 'api').resolves(mockPythonEnvApi);
478-
479-
const result = await pythonApi.getInterpreters();
480-
481-
expect(result).to.deep.equal([]);
482-
});
483-
484-
test('Should return empty array when known is null', async () => {
485-
mockPythonEnvApi.environments.known = null;
486-
sinon.stub(PythonExtension, 'api').resolves(mockPythonEnvApi);
487-
488-
const result = await pythonApi.getInterpreters();
489-
490-
expect(result).to.deep.equal([]);
491-
});
492-
});
493-
494418
suite('onDidChangePythonInterpreter event', () => {
495419
test('Should fire event when active environment path changes', async () => {
496420
const disposables: Disposable[] = [];

src/test/unittest/common/pythonTrue.unit.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as sinon from 'sinon';
88
import { Uri, Disposable, Extension, extensions } from 'vscode';
99
import * as pythonApi from '../../../extension/common/python';
1010
import * as utilities from '../../../extension/common/utilities';
11-
import { Environment, EnvironmentPath } from '@vscode/python-extension';
11+
import { EnvironmentPath } from '@vscode/python-extension';
1212
import { buildPythonEnvironment } from './helpers';
1313

1414
suite('Python API Tests- useEnvironmentsExtension:true', () => {
@@ -218,11 +218,6 @@ suite('Python API Tests- useEnvironmentsExtension:true', () => {
218218
});
219219

220220
test('Should resolve environment from Environment object', async () => {
221-
const env: Environment = {
222-
id: 'test-env',
223-
path: '/usr/bin/python3',
224-
version: { major: 3, minor: 9, micro: 0 },
225-
} as Environment;
226221
// Use buildPythonEnvironment for realistic mock
227222
const expectedEnv = buildPythonEnvironment('/usr/bin/python3', '3.9.0');
228223

0 commit comments

Comments
 (0)