@@ -11,6 +11,7 @@ import {
11
11
getEnvLocationHeuristic ,
12
12
} from '../../client/interpreter/configuration/environmentTypeComparer' ;
13
13
import { IInterpreterHelper } from '../../client/interpreter/contracts' ;
14
+ import { PythonEnvType } from '../../client/pythonEnvironments/base/info' ;
14
15
import { EnvironmentType , PythonEnvironment } from '../../client/pythonEnvironments/info' ;
15
16
16
17
suite ( 'Environment sorting' , ( ) => {
@@ -45,6 +46,7 @@ suite('Environment sorting', () => {
45
46
title : 'Local virtual environment should come first' ,
46
47
envA : {
47
48
envType : EnvironmentType . Venv ,
49
+ type : PythonEnvType . Virtual ,
48
50
envPath : path . join ( workspacePath , '.venv' ) ,
49
51
version : { major : 3 , minor : 10 , patch : 2 } ,
50
52
} as PythonEnvironment ,
@@ -58,11 +60,13 @@ suite('Environment sorting', () => {
58
60
title : "Non-local virtual environment should not come first when there's a local env" ,
59
61
envA : {
60
62
envType : EnvironmentType . Venv ,
63
+ type : PythonEnvType . Virtual ,
61
64
envPath : path . join ( 'path' , 'to' , 'other' , 'workspace' , '.venv' ) ,
62
65
version : { major : 3 , minor : 10 , patch : 2 } ,
63
66
} as PythonEnvironment ,
64
67
envB : {
65
68
envType : EnvironmentType . Venv ,
69
+ type : PythonEnvType . Virtual ,
66
70
envPath : path . join ( workspacePath , '.venv' ) ,
67
71
version : { major : 3 , minor : 10 , patch : 2 } ,
68
72
} as PythonEnvironment ,
@@ -72,10 +76,12 @@ suite('Environment sorting', () => {
72
76
title : "Conda environment should not come first when there's a local env" ,
73
77
envA : {
74
78
envType : EnvironmentType . Conda ,
79
+ type : PythonEnvType . Conda ,
75
80
version : { major : 3 , minor : 10 , patch : 2 } ,
76
81
} as PythonEnvironment ,
77
82
envB : {
78
83
envType : EnvironmentType . Venv ,
84
+ type : PythonEnvType . Virtual ,
79
85
envPath : path . join ( workspacePath , '.venv' ) ,
80
86
version : { major : 3 , minor : 10 , patch : 2 } ,
81
87
} as PythonEnvironment ,
@@ -85,11 +91,13 @@ suite('Environment sorting', () => {
85
91
title : 'Conda base environment should come after any other conda env' ,
86
92
envA : {
87
93
envType : EnvironmentType . Conda ,
94
+ type : PythonEnvType . Conda ,
88
95
envName : 'base' ,
89
96
version : { major : 3 , minor : 10 , patch : 2 } ,
90
97
} as PythonEnvironment ,
91
98
envB : {
92
99
envType : EnvironmentType . Conda ,
100
+ type : PythonEnvType . Conda ,
93
101
envName : 'random-name' ,
94
102
version : { major : 3 , minor : 10 , patch : 2 } ,
95
103
} as PythonEnvironment ,
@@ -99,6 +107,7 @@ suite('Environment sorting', () => {
99
107
title : 'Pipenv environment should come before any other conda env' ,
100
108
envA : {
101
109
envType : EnvironmentType . Conda ,
110
+ type : PythonEnvType . Conda ,
102
111
envName : 'conda-env' ,
103
112
version : { major : 3 , minor : 10 , patch : 2 } ,
104
113
} as PythonEnvironment ,
@@ -118,19 +127,21 @@ suite('Environment sorting', () => {
118
127
} as PythonEnvironment ,
119
128
envB : {
120
129
envType : EnvironmentType . Poetry ,
130
+ type : PythonEnvType . Virtual ,
121
131
envName : 'poetry-env' ,
122
132
version : { major : 3 , minor : 10 , patch : 2 } ,
123
133
} as PythonEnvironment ,
124
134
expected : 1 ,
125
135
} ,
126
136
{
127
- title : 'Pyenv environment should not come first when there are global envs' ,
137
+ title : 'Pyenv interpreter should not come first when there are global envs' ,
128
138
envA : {
129
139
envType : EnvironmentType . Pyenv ,
130
140
version : { major : 3 , minor : 10 , patch : 2 } ,
131
141
} as PythonEnvironment ,
132
142
envB : {
133
143
envType : EnvironmentType . Pipenv ,
144
+ type : PythonEnvType . Virtual ,
134
145
envName : 'pipenv-env' ,
135
146
version : { major : 3 , minor : 10 , patch : 2 } ,
136
147
} as PythonEnvironment ,
@@ -144,6 +155,7 @@ suite('Environment sorting', () => {
144
155
} as PythonEnvironment ,
145
156
envB : {
146
157
envType : EnvironmentType . Poetry ,
158
+ type : PythonEnvType . Virtual ,
147
159
envName : 'poetry-env' ,
148
160
version : { major : 3 , minor : 10 , patch : 2 } ,
149
161
} as PythonEnvironment ,
@@ -157,11 +169,25 @@ suite('Environment sorting', () => {
157
169
} as PythonEnvironment ,
158
170
envB : {
159
171
envType : EnvironmentType . VirtualEnv ,
172
+ type : PythonEnvType . Virtual ,
160
173
envName : 'virtualenv-env' ,
161
174
version : { major : 3 , minor : 10 , patch : 2 } ,
162
175
} as PythonEnvironment ,
163
176
expected : 1 ,
164
177
} ,
178
+ {
179
+ title :
180
+ 'Microsoft Store interpreter should not come first when there are global interpreters with higher version' ,
181
+ envA : {
182
+ envType : EnvironmentType . MicrosoftStore ,
183
+ version : { major : 3 , minor : 10 , patch : 2 , raw : '3.10.2' } ,
184
+ } as PythonEnvironment ,
185
+ envB : {
186
+ envType : EnvironmentType . Global ,
187
+ version : { major : 3 , minor : 11 , patch : 2 , raw : '3.11.2' } ,
188
+ } as PythonEnvironment ,
189
+ expected : 1 ,
190
+ } ,
165
191
{
166
192
title : 'Unknown environment should not come first when there are global envs' ,
167
193
envA : {
@@ -170,6 +196,7 @@ suite('Environment sorting', () => {
170
196
} as PythonEnvironment ,
171
197
envB : {
172
198
envType : EnvironmentType . Pipenv ,
199
+ type : PythonEnvType . Virtual ,
173
200
envName : 'pipenv-env' ,
174
201
version : { major : 3 , minor : 10 , patch : 2 } ,
175
202
} as PythonEnvironment ,
@@ -179,11 +206,13 @@ suite('Environment sorting', () => {
179
206
title : 'If 2 environments are of the same type, the most recent Python version comes first' ,
180
207
envA : {
181
208
envType : EnvironmentType . Venv ,
209
+ type : PythonEnvType . Virtual ,
182
210
envPath : path . join ( workspacePath , '.old-venv' ) ,
183
211
version : { major : 3 , minor : 7 , patch : 5 , raw : '3.7.5' } ,
184
212
} as PythonEnvironment ,
185
213
envB : {
186
214
envType : EnvironmentType . Venv ,
215
+ type : PythonEnvType . Virtual ,
187
216
envPath : path . join ( workspacePath , '.venv' ) ,
188
217
version : { major : 3 , minor : 10 , patch : 2 , raw : '3.10.2' } ,
189
218
} as PythonEnvironment ,
@@ -194,11 +223,13 @@ suite('Environment sorting', () => {
194
223
"If 2 global environments have the same Python version and there's a Conda one, the Conda env should not come first" ,
195
224
envA : {
196
225
envType : EnvironmentType . Conda ,
226
+ type : PythonEnvType . Conda ,
197
227
envName : 'conda-env' ,
198
228
version : { major : 3 , minor : 10 , patch : 2 } ,
199
229
} as PythonEnvironment ,
200
230
envB : {
201
231
envType : EnvironmentType . Pipenv ,
232
+ type : PythonEnvType . Virtual ,
202
233
envName : 'pipenv-env' ,
203
234
version : { major : 3 , minor : 10 , patch : 2 } ,
204
235
} as PythonEnvironment ,
@@ -209,11 +240,13 @@ suite('Environment sorting', () => {
209
240
'If 2 global environments are of the same type and have the same Python version, they should be sorted by name' ,
210
241
envA : {
211
242
envType : EnvironmentType . Conda ,
243
+ type : PythonEnvType . Conda ,
212
244
envName : 'conda-foo' ,
213
245
version : { major : 3 , minor : 10 , patch : 2 } ,
214
246
} as PythonEnvironment ,
215
247
envB : {
216
248
envType : EnvironmentType . Conda ,
249
+ type : PythonEnvType . Conda ,
217
250
envName : 'conda-bar' ,
218
251
version : { major : 3 , minor : 10 , patch : 2 } ,
219
252
} as PythonEnvironment ,
@@ -237,6 +270,7 @@ suite('Environment sorting', () => {
237
270
title : 'Problematic environments should come last' ,
238
271
envA : {
239
272
envType : EnvironmentType . Conda ,
273
+ type : PythonEnvType . Conda ,
240
274
envPath : path . join ( workspacePath , '.venv' ) ,
241
275
path : 'python' ,
242
276
} as PythonEnvironment ,
0 commit comments