@@ -29,7 +29,12 @@ import { CommandsWithoutArgs } from '../../../../client/common/application/comma
29
29
import { IPlatformService } from '../../../../client/common/platform/types' ;
30
30
import { IConfigurationService , IDisposableRegistry , IPythonSettings } from '../../../../client/common/types' ;
31
31
import { noop } from '../../../../client/common/utils/misc' ;
32
- import { IInterpreterHelper , IInterpreterService , InterpreterType } from '../../../../client/interpreter/contracts' ;
32
+ import {
33
+ IInterpreterHelper ,
34
+ IInterpreterService ,
35
+ InterpreterType ,
36
+ PythonInterpreter
37
+ } from '../../../../client/interpreter/contracts' ;
33
38
import { IServiceContainer } from '../../../../client/ioc/types' ;
34
39
35
40
suite ( 'Application Diagnostics - Checks Python Interpreter' , ( ) => {
@@ -129,7 +134,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
129
134
expect ( diagnostics ) . to . be . deep . equal ( [ ] ) ;
130
135
settings . verifyAll ( ) ;
131
136
} ) ;
132
- test ( 'Should return diagnostics if there are no interpreters' , async ( ) => {
137
+ test ( 'Should return diagnostics if there are no interpreters after double-checking ' , async ( ) => {
133
138
settings
134
139
. setup ( ( s ) => s . disableInstallationChecks )
135
140
. returns ( ( ) => false )
@@ -138,6 +143,10 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
138
143
. setup ( ( i ) => i . hasInterpreters )
139
144
. returns ( ( ) => Promise . resolve ( false ) )
140
145
. verifiable ( typemoq . Times . once ( ) ) ;
146
+ interpreterService
147
+ . setup ( ( i ) => i . getInterpreters ( undefined ) )
148
+ . returns ( ( ) => Promise . resolve ( [ ] ) )
149
+ . verifiable ( typemoq . Times . once ( ) ) ;
141
150
142
151
const diagnostics = await diagnosticService . diagnose ( undefined ) ;
143
152
expect ( diagnostics ) . to . be . deep . equal (
@@ -147,6 +156,34 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
147
156
settings . verifyAll ( ) ;
148
157
interpreterService . verifyAll ( ) ;
149
158
} ) ;
159
+ test ( 'Should return empty diagnostics if there are interpreters after double-checking' , async ( ) => {
160
+ const interpreter : PythonInterpreter = { type : InterpreterType . Unknown } as any ;
161
+
162
+ settings
163
+ . setup ( ( s ) => s . disableInstallationChecks )
164
+ . returns ( ( ) => false )
165
+ . verifiable ( typemoq . Times . once ( ) ) ;
166
+ interpreterService
167
+ . setup ( ( i ) => i . hasInterpreters )
168
+ . returns ( ( ) => Promise . resolve ( false ) )
169
+ . verifiable ( typemoq . Times . once ( ) ) ;
170
+ interpreterService
171
+ . setup ( ( i ) => i . getInterpreters ( undefined ) )
172
+ . returns ( ( ) => Promise . resolve ( [ interpreter ] ) )
173
+ . verifiable ( typemoq . Times . once ( ) ) ;
174
+ interpreterService
175
+ . setup ( ( i ) => i . getActiveInterpreter ( typemoq . It . isAny ( ) ) )
176
+ . returns ( ( ) => {
177
+ return Promise . resolve ( interpreter ) ;
178
+ } )
179
+ . verifiable ( typemoq . Times . once ( ) ) ;
180
+
181
+ const diagnostics = await diagnosticService . diagnose ( undefined ) ;
182
+
183
+ expect ( diagnostics ) . to . be . deep . equal ( [ ] , 'not the same' ) ;
184
+ settings . verifyAll ( ) ;
185
+ interpreterService . verifyAll ( ) ;
186
+ } ) ;
150
187
test ( 'Should return invalid diagnostics if there are interpreters but no current interpreter' , async ( ) => {
151
188
settings
152
189
. setup ( ( s ) => s . disableInstallationChecks )
0 commit comments