@@ -41,14 +41,15 @@ suite('Python Settings', async () => {
4141 let config : TypeMoq . IMock < WorkspaceConfiguration > ;
4242 let expected : CustomPythonSettings ;
4343 let settings : CustomPythonSettings ;
44+ let extensions : MockExtensions ;
4445 setup ( ( ) => {
4546 sinon . stub ( EnvFileTelemetry , 'sendSettingTelemetry' ) . returns ( ) ;
4647 config = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( undefined , TypeMoq . MockBehavior . Loose ) ;
4748
4849 const workspaceService = new WorkspaceService ( ) ;
4950 const workspaceMemento = new MockMemento ( ) ;
5051 const globalMemento = new MockMemento ( ) ;
51- const extensions = new MockExtensions ( ) ;
52+ extensions = new MockExtensions ( ) ;
5253 const persistentStateFactory = new PersistentStateFactory ( globalMemento , workspaceMemento ) ;
5354 expected = new CustomPythonSettings (
5455 undefined ,
@@ -57,7 +58,7 @@ suite('Python Settings', async () => {
5758 new InterpreterPathService ( persistentStateFactory , workspaceService , [ ] , {
5859 remoteName : undefined ,
5960 } as IApplicationEnvironment ) ,
60- undefined ,
61+ { defaultLSType : LanguageServerType . Jedi } ,
6162 extensions ,
6263 ) ;
6364 settings = new CustomPythonSettings (
@@ -67,7 +68,7 @@ suite('Python Settings', async () => {
6768 new InterpreterPathService ( persistentStateFactory , workspaceService , [ ] , {
6869 remoteName : undefined ,
6970 } as IApplicationEnvironment ) ,
70- undefined ,
71+ { defaultLSType : LanguageServerType . Jedi } ,
7172 extensions ,
7273 ) ;
7374 expected . defaultInterpreterPath = 'python' ;
@@ -230,7 +231,7 @@ suite('Python Settings', async () => {
230231 const values = [
231232 { ls : LanguageServerType . Jedi , expected : LanguageServerType . Jedi , default : false } ,
232233 { ls : LanguageServerType . JediLSP , expected : LanguageServerType . Jedi , default : false } ,
233- { ls : LanguageServerType . Microsoft , expected : LanguageServerType . None , default : true } ,
234+ { ls : LanguageServerType . Microsoft , expected : LanguageServerType . Jedi , default : true } ,
234235 { ls : LanguageServerType . Node , expected : LanguageServerType . Node , default : false } ,
235236 { ls : LanguageServerType . None , expected : LanguageServerType . None , default : false } ,
236237 ] ;
@@ -239,7 +240,48 @@ suite('Python Settings', async () => {
239240 testLanguageServer ( v . ls , v . expected , v . default ) ;
240241 } ) ;
241242
242- testLanguageServer ( 'invalid' as LanguageServerType , LanguageServerType . None , true ) ;
243+ testLanguageServer ( 'invalid' as LanguageServerType , LanguageServerType . Jedi , true ) ;
244+ } ) ;
245+
246+ function testPyreflySettings ( pyreflyInstalled : boolean , pyreflyDisabled : boolean , languageServerDisabled : boolean ) {
247+ test ( `pyrefly ${ pyreflyInstalled ? 'installed' : 'not installed' } and ${
248+ pyreflyDisabled ? 'disabled' : 'enabled'
249+ } `, ( ) => {
250+ if ( pyreflyInstalled ) {
251+ extensions . extensionIdsToFind = [ 'meta.pyrefly' ] ;
252+ } else {
253+ extensions . extensionIdsToFind = [ ] ;
254+ }
255+ config . setup ( ( c ) => c . get < boolean > ( 'pyrefly.disableLanguageServices' ) ) . returns ( ( ) => pyreflyDisabled ) ;
256+
257+ config
258+ . setup ( ( c ) => c . get < string > ( 'languageServer' ) )
259+ . returns ( ( ) => undefined )
260+ . verifiable ( TypeMoq . Times . once ( ) ) ;
261+
262+ settings . update ( config . object ) ;
263+
264+ if ( languageServerDisabled ) {
265+ expect ( settings . languageServer ) . to . equal ( LanguageServerType . None ) ;
266+ } else {
267+ expect ( settings . languageServer ) . not . to . equal ( LanguageServerType . None ) ;
268+ }
269+ expect ( settings . languageServerIsDefault ) . to . equal ( true ) ;
270+ config . verifyAll ( ) ;
271+ } ) ;
272+ }
273+
274+ suite ( 'pyrefly languageServer settings' , async ( ) => {
275+ const values = [
276+ { pyreflyInstalled : true , pyreflyDisabled : false , languageServerDisabled : true } ,
277+ { pyreflyInstalled : true , pyreflyDisabled : true , languageServerDisabled : false } ,
278+ { pyreflyInstalled : false , pyreflyDisabled : true , languageServerDisabled : false } ,
279+ { pyreflyInstalled : false , pyreflyDisabled : false , languageServerDisabled : false } ,
280+ ] ;
281+
282+ values . forEach ( ( v ) => {
283+ testPyreflySettings ( v . pyreflyInstalled , v . pyreflyDisabled , v . languageServerDisabled ) ;
284+ } ) ;
243285 } ) ;
244286
245287 function testExperiments ( enabled : boolean ) {
0 commit comments