Skip to content

Commit 9932f43

Browse files
committed
Fix tests
1 parent 8b3b976 commit 9932f43

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/client/pythonEnvironments/nativeAPI.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,32 @@ function toPythonEnvInfo(nativeEnv: NativeEnvInfo): PythonEnvInfo | undefined {
210210
};
211211
}
212212

213+
function hasChanged(old: PythonEnvInfo, newEnv: PythonEnvInfo): boolean {
214+
if (old.executable.filename !== newEnv.executable.filename) {
215+
return true;
216+
}
217+
if (old.version.major !== newEnv.version.major) {
218+
return true;
219+
}
220+
if (old.version.minor !== newEnv.version.minor) {
221+
return true;
222+
}
223+
if (old.version.micro !== newEnv.version.micro) {
224+
return true;
225+
}
226+
if (old.location !== newEnv.location) {
227+
return true;
228+
}
229+
if (old.kind !== newEnv.kind) {
230+
return true;
231+
}
232+
if (old.arch !== newEnv.arch) {
233+
return true;
234+
}
235+
236+
return false;
237+
}
238+
213239
class NativePythonEnvironments implements IDiscoveryAPI, Disposable {
214240
private _onProgress: EventEmitter<ProgressNotificationEvent>;
215241

@@ -354,37 +380,11 @@ class NativePythonEnvironments implements IDiscoveryAPI, Disposable {
354380
return this._envs;
355381
}
356382

357-
private hasChanged(old: PythonEnvInfo, newEnv: PythonEnvInfo): boolean {
358-
if (old.executable.filename !== newEnv.executable.filename) {
359-
return true;
360-
}
361-
if (old.version.major !== newEnv.version.major) {
362-
return true;
363-
}
364-
if (old.version.minor !== newEnv.version.minor) {
365-
return true;
366-
}
367-
if (old.version.micro !== newEnv.version.micro) {
368-
return true;
369-
}
370-
if (old.location !== newEnv.location) {
371-
return true;
372-
}
373-
if (old.kind !== newEnv.kind) {
374-
return true;
375-
}
376-
if (old.arch !== newEnv.arch) {
377-
return true;
378-
}
379-
380-
return false;
381-
}
382-
383383
private addEnv(native: NativeEnvInfo, searchLocation?: Uri): PythonEnvInfo | undefined {
384384
const info = toPythonEnvInfo(native);
385385
if (info) {
386386
const old = this._envs.find((item) => item.executable.filename === info.executable.filename);
387-
if (old && this.hasChanged(old, info)) {
387+
if (old && hasChanged(old, info)) {
388388
this._envs = this._envs.filter((item) => item.executable.filename !== info.executable.filename);
389389
this._envs.push(info);
390390
this._onChanged.fire({ type: FileChangeType.Changed, old, new: info, searchLocation });

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ suite('Native Python API', () => {
108108
mtime: -1,
109109
},
110110
kind: PythonEnvKind.Conda,
111-
location: '/home/user/.conda/envs/conda_python/python',
111+
location: '/home/user/.conda/envs/conda_python',
112112
source: [],
113113
name: 'conda_python',
114114
type: PythonEnvType.Conda,

0 commit comments

Comments
 (0)