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