Skip to content

Commit 855cdf5

Browse files
committed
.
1 parent af93b59 commit 855cdf5

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/managers/builtin/pipUtils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ export async function getProjectInstallable(
190190
).flat();
191191

192192
// Deduplicate by fsPath
193-
const uniqueResults = Array.from(
194-
new Map(results.map((uri) => [uri.fsPath, uri])).values(),
195-
);
193+
const uniqueResults = Array.from(new Map(results.map((uri) => [uri.fsPath, uri])).values());
196194

197195
const fsPaths = projects.map((p) => p.uri.fsPath);
198196
const filtered = uniqueResults

src/test/managers/builtin/pipUtils.unit.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ suite('Pip Utils - getProjectInstallable', () => {
3333
},
3434
);
3535

36-
const workspacePath = path.resolve('/workspace');
36+
const workspacePath = Uri.file('/test/path/root').fsPath;
3737
mockApi = {
3838
getPythonProject: (uri: Uri) => {
3939
// Return a project for any URI in workspace
@@ -57,7 +57,7 @@ suite('Pip Utils - getProjectInstallable', () => {
5757
return Promise.resolve([]);
5858
} else if (pattern === '*requirements*.txt') {
5959
// This pattern should match root-level files
60-
const workspacePath = path.resolve('/workspace');
60+
const workspacePath = Uri.file('/test/path/root').fsPath;
6161
return Promise.resolve([
6262
Uri.file(path.join(workspacePath, 'requirements.txt')),
6363
Uri.file(path.join(workspacePath, 'dev-requirements.txt')),
@@ -72,7 +72,7 @@ suite('Pip Utils - getProjectInstallable', () => {
7272
});
7373

7474
// Act: Call getProjectInstallable
75-
const workspacePath = path.resolve('/workspace');
75+
const workspacePath = Uri.file('/test/path/root').fsPath;
7676
const projects = [{ name: 'workspace', uri: Uri.file(workspacePath) }];
7777
const result = await getProjectInstallable(mockApi as PythonEnvironmentApi, projects);
7878

@@ -100,10 +100,10 @@ suite('Pip Utils - getProjectInstallable', () => {
100100
// Arrange: Mock both patterns to return the same file
101101
findFilesStub.callsFake((pattern: string) => {
102102
if (pattern === '**/*requirements*.txt') {
103-
const workspacePath = path.resolve('/workspace');
103+
const workspacePath = Uri.file('/test/path/root').fsPath;
104104
return Promise.resolve([Uri.file(path.join(workspacePath, 'dev-requirements.txt'))]);
105105
} else if (pattern === '*requirements*.txt') {
106-
const workspacePath = path.resolve('/workspace');
106+
const workspacePath = Uri.file('/test/path/root').fsPath;
107107
return Promise.resolve([
108108
Uri.file(path.join(workspacePath, 'dev-requirements.txt')),
109109
Uri.file(path.join(workspacePath, 'requirements.txt')),
@@ -117,7 +117,7 @@ suite('Pip Utils - getProjectInstallable', () => {
117117
});
118118

119119
// Act: Call getProjectInstallable
120-
const workspacePath = path.resolve('/workspace');
120+
const workspacePath = Uri.file('/test/path/root').fsPath;
121121
const projects = [{ name: 'workspace', uri: Uri.file(workspacePath) }];
122122
const result = await getProjectInstallable(mockApi as PythonEnvironmentApi, projects);
123123

@@ -132,13 +132,13 @@ suite('Pip Utils - getProjectInstallable', () => {
132132
// Arrange: Mock findFiles to return files in subdirectories
133133
findFilesStub.callsFake((pattern: string) => {
134134
if (pattern === '**/*requirements*.txt') {
135-
const workspacePath = path.resolve('/workspace');
135+
const workspacePath = Uri.file('/test/path/root').fsPath;
136136
return Promise.resolve([Uri.file(path.join(workspacePath, 'subdir', 'dev-requirements.txt'))]);
137137
} else if (pattern === '*requirements*.txt') {
138-
const workspacePath = path.resolve('/workspace');
138+
const workspacePath = Uri.file('/test/path/root').fsPath;
139139
return Promise.resolve([Uri.file(path.join(workspacePath, 'requirements.txt'))]);
140140
} else if (pattern === '**/requirements/*.txt') {
141-
const workspacePath = path.resolve('/workspace');
141+
const workspacePath = Uri.file('/test/path/root').fsPath;
142142
return Promise.resolve([Uri.file(path.join(workspacePath, 'requirements', 'test.txt'))]);
143143
} else if (pattern === '**/pyproject.toml') {
144144
return Promise.resolve([]);
@@ -147,7 +147,7 @@ suite('Pip Utils - getProjectInstallable', () => {
147147
});
148148

149149
// Act: Call getProjectInstallable
150-
const workspacePath = path.resolve('/workspace');
150+
const workspacePath = Uri.file('/test/path/root').fsPath;
151151
const projects = [{ name: 'workspace', uri: Uri.file(workspacePath) }];
152152
const result = await getProjectInstallable(mockApi as PythonEnvironmentApi, projects);
153153

@@ -175,8 +175,8 @@ suite('Pip Utils - getProjectInstallable', () => {
175175
// Arrange: Mock findFiles to return files from multiple directories
176176
findFilesStub.callsFake((pattern: string) => {
177177
if (pattern === '*requirements*.txt') {
178-
const workspacePath = path.resolve('/workspace');
179-
const otherPath = path.resolve('/other-dir');
178+
const workspacePath = Uri.file('/test/path/root').fsPath;
179+
const otherPath = Uri.file('/other-dir').fsPath;
180180
return Promise.resolve([
181181
Uri.file(path.join(workspacePath, 'requirements.txt')),
182182
Uri.file(path.join(otherPath, 'requirements.txt')), // Should be filtered out
@@ -187,7 +187,7 @@ suite('Pip Utils - getProjectInstallable', () => {
187187
});
188188

189189
// Act: Call with only workspace project
190-
const workspacePath = path.resolve('/workspace');
190+
const workspacePath = Uri.file('/test/path/root').fsPath;
191191
const projects = [{ name: 'workspace', uri: Uri.file(workspacePath) }];
192192
const result = await getProjectInstallable(mockApi as PythonEnvironmentApi, projects);
193193

0 commit comments

Comments
 (0)