26
26
usermain = testcfg ['main' ] = config .IdleUserConfParser ('' )
27
27
userhigh = testcfg ['highlight' ] = config .IdleUserConfParser ('' )
28
28
userkeys = testcfg ['keys' ] = config .IdleUserConfParser ('' )
29
+ userextn = testcfg ['extensions' ] = config .IdleUserConfParser ('' )
29
30
30
31
def setUpModule ():
31
32
idleConf .userCfg = testcfg
@@ -430,29 +431,22 @@ def test_default_keys(self):
430
431
sys .platform = current_platform
431
432
432
433
def test_get_extensions (self ):
433
- conf = self .mock_config ()
434
-
435
- # Add disable extensions
436
- conf .SetOption ('extensions' , 'DISABLE' , 'enable' , 'False' )
437
-
434
+ userextn .read_string ('''
435
+ [ZzDummy]
436
+ enable = True
437
+ [DISABLE]
438
+ enable = False
439
+ ''' )
438
440
eq = self .assertEqual
439
- eq (conf .GetExtensions (),
440
- ['ZzDummy' ])
441
- eq (conf .GetExtensions (active_only = False ),
442
- ['ZzDummy' , 'DISABLE' ])
443
- eq (conf .GetExtensions (editor_only = True ),
444
- ['ZzDummy' ])
445
- eq (conf .GetExtensions (shell_only = True ),
446
- [])
447
- eq (conf .GetExtensions (active_only = False , editor_only = True ),
448
- ['ZzDummy' , 'DISABLE' ])
449
-
450
- # Add user extensions
451
- conf .SetOption ('extensions' , 'Foobar' , 'enable' , 'True' )
452
- eq (conf .GetExtensions (),
453
- ['ZzDummy' , 'Foobar' ]) # User extensions didn't sort
454
- eq (conf .GetExtensions (active_only = False ),
455
- ['ZzDummy' , 'DISABLE' , 'Foobar' ])
441
+ iGE = idleConf .GetExtensions
442
+ eq (iGE (shell_only = True ), [])
443
+ eq (iGE (), ['ZzDummy' ])
444
+ eq (iGE (editor_only = True ), ['ZzDummy' ])
445
+ eq (iGE (active_only = False ), ['ZzDummy' , 'DISABLE' ])
446
+ eq (iGE (active_only = False , editor_only = True ), ['ZzDummy' , 'DISABLE' ])
447
+ userextn .remove_section ('ZzDummy' )
448
+ userextn .remove_section ('DISABLE' )
449
+
456
450
457
451
def test_remove_key_bind_names (self ):
458
452
conf = self .mock_config ()
@@ -462,39 +456,39 @@ def test_remove_key_bind_names(self):
462
456
['AutoComplete' , 'CodeContext' , 'FormatParagraph' , 'ParenMatch' ,'ZzDummy' ])
463
457
464
458
def test_get_extn_name_for_event (self ):
465
- conf = self .mock_config ()
466
-
459
+ userextn .read_string ('''
460
+ [ZzDummy]
461
+ enable = True
462
+ ''' )
467
463
eq = self .assertEqual
468
- eq (conf .GetExtnNameForEvent ('z-in' ), 'ZzDummy' )
469
- eq (conf .GetExtnNameForEvent ('z-out' ), None )
464
+ eq (idleConf .GetExtnNameForEvent ('z-in' ), 'ZzDummy' )
465
+ eq (idleConf .GetExtnNameForEvent ('z-out' ), None )
466
+ userextn .remove_section ('ZzDummy' )
470
467
471
468
def test_get_extension_keys (self ):
472
- conf = self .mock_config ()
473
-
474
- eq = self .assertEqual
475
- eq (conf .GetExtensionKeys ('ZzDummy' ),
469
+ userextn .read_string ('''
470
+ [ZzDummy]
471
+ enable = True
472
+ ''' )
473
+ self .assertEqual (idleConf .GetExtensionKeys ('ZzDummy' ),
476
474
{'<<z-in>>' : ['<Control-Shift-KeyRelease-Insert>' ]})
475
+ userextn .remove_section ('ZzDummy' )
477
476
# need option key test
478
477
## key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>']
479
478
## eq(conf.GetExtensionKeys('ZoomHeight'), {'<<zoom-height>>': key})
480
479
481
480
def test_get_extension_bindings (self ):
482
- conf = self .mock_config ()
483
-
484
- self .assertEqual (conf .GetExtensionBindings ('NotExists' ), {})
485
-
486
- #key = ['<Option-Key-2>'] if sys.platform == 'darwin' else ['<Alt-Key-2>']
481
+ userextn .read_string ('''
482
+ [ZzDummy]
483
+ enable = True
484
+ ''' )
485
+ eq = self .assertEqual
486
+ iGEB = idleConf .GetExtensionBindings
487
+ eq (iGEB ('NotExists' ), {})
487
488
expect = {'<<z-in>>' : ['<Control-Shift-KeyRelease-Insert>' ],
488
489
'<<z-out>>' : ['<Control-Shift-KeyRelease-Delete>' ]}
489
- self .assertEqual (
490
- conf .GetExtensionBindings ('ZzDummy' ), expect )
491
-
492
- # Add non-configuarable bindings
493
- conf .defaultCfg ['extensions' ].add_section ('Foobar' )
494
- conf .defaultCfg ['extensions' ].add_section ('Foobar_bindings' )
495
- conf .defaultCfg ['extensions' ].set ('Foobar' , 'enable' , 'True' )
496
- conf .defaultCfg ['extensions' ].set ('Foobar_bindings' , 'foobar' , '<Key-F>' )
497
- self .assertEqual (conf .GetExtensionBindings ('Foobar' ), {'<<foobar>>' : ['<Key-F>' ]})
490
+ eq (iGEB ('ZzDummy' ), expect )
491
+ userextn .remove_section ('ZzDummy' )
498
492
499
493
def test_get_keybinding (self ):
500
494
conf = self .mock_config ()
0 commit comments