def test_create_new_key_set_and_save_new_key_set(self): eq = self.assertEqual d = self.page # Use default as previously active keyset. d.keyset_source.set(True) d.builtin_name.set('IDLE Classic Windows') first_new = 'my new custom key set' second_new = 'my second custom keyset' # No changes, so keysets are an exact copy. self.assertNotIn(first_new, idleConf.userCfg) d.create_new_key_set(first_new) eq(idleConf.GetSectionList('user', 'keys'), [first_new]) eq(idleConf.GetKeySet('IDLE Classic Windows'), idleConf.GetKeySet(first_new)) eq(d.custom_name.get(), first_new) self.assertFalse(d.keyset_source.get()) # Use custom set. eq(d.set_keys_type.called, 1) # Test that changed keybindings are in new keyset. changes.add_option('keys', first_new, 'copy', '<Key-F11>') self.assertNotIn(second_new, idleConf.userCfg) d.create_new_key_set(second_new) eq(idleConf.GetSectionList('user', 'keys'), [first_new, second_new]) self.assertNotEqual(idleConf.GetKeySet(first_new), idleConf.GetKeySet(second_new)) # Check that difference in keysets was in option `copy` from `changes`. idleConf.SetOption('keys', first_new, 'copy', '<Key-F11>') eq(idleConf.GetKeySet(first_new), idleConf.GetKeySet(second_new))
def test_create_new_and_save_new(self): eq = self.assertEqual d = self.page # Use default as previously active theme. d.theme_source.set(True) d.builtin_name.set('IDLE Classic') first_new = 'my new custom theme' second_new = 'my second custom theme' # No changes, so themes are an exact copy. self.assertNotIn(first_new, idleConf.userCfg) d.create_new(first_new) eq(idleConf.GetSectionList('user', 'highlight'), [first_new]) eq(idleConf.GetThemeDict('default', 'IDLE Classic'), idleConf.GetThemeDict('user', first_new)) eq(d.custom_name.get(), first_new) self.assertFalse(d.theme_source.get()) # Use custom set. eq(d.set_theme_type.called, 1) # Test that changed targets are in new theme. changes.add_option('highlight', first_new, 'hit-background', 'yellow') self.assertNotIn(second_new, idleConf.userCfg) d.create_new(second_new) eq(idleConf.GetSectionList('user', 'highlight'), [first_new, second_new]) self.assertNotEqual(idleConf.GetThemeDict('user', first_new), idleConf.GetThemeDict('user', second_new)) # Check that difference in themes was in `hit-background` from `changes`. idleConf.SetOption('highlight', first_new, 'hit-background', 'yellow') eq(idleConf.GetThemeDict('user', first_new), idleConf.GetThemeDict('user', second_new))
def setUp(self): d = self.page # The following is needed for test_load_key_cfg, _delete_custom_keys. # This may indicate a defect in some test or function. for section in idleConf.GetSectionList('user', 'keys'): idleConf.userCfg['keys'].remove_section(section) changes.clear() d.set_keys_type.called = 0 d.load_keys_list.called = 0
def setUp(self): d = self.page # The following is needed for test_load_key_cfg, _delete_custom_keys. # This may indicate a defect in some test or function. for section in idleConf.GetSectionList('user', 'highlight'): idleConf.userCfg['highlight'].remove_section(section) changes.clear() d.set_theme_type.called = 0 d.paint_theme_sample.called = 0 d.set_highlight_target.called = 0 d.set_color_sample.called = 0
def test_delete_custom(self): eq = self.assertEqual d = self.page d.button_delete_custom.state(('!disabled',)) yesno = d.askyesno = Func() dialog.deactivate_current_config = Func() dialog.activate_config_changes = Func() theme_name = 'spam theme' idleConf.userCfg['highlight'].SetOption(theme_name, 'name', 'value') highpage[theme_name] = {'option': 'True'} # Force custom theme. d.theme_source.set(False) d.custom_name.set(theme_name) # Cancel deletion. yesno.result = False d.button_delete_custom.invoke() eq(yesno.called, 1) eq(highpage[theme_name], {'option': 'True'}) eq(idleConf.GetSectionList('user', 'highlight'), ['spam theme']) eq(dialog.deactivate_current_config.called, 0) eq(dialog.activate_config_changes.called, 0) eq(d.set_theme_type.called, 0) # Confirm deletion. yesno.result = True d.button_delete_custom.invoke() eq(yesno.called, 2) self.assertNotIn(theme_name, highpage) eq(idleConf.GetSectionList('user', 'highlight'), []) eq(d.custom_theme_on.state(), ('disabled',)) eq(d.custom_name.get(), '- no custom themes -') eq(dialog.deactivate_current_config.called, 1) eq(dialog.activate_config_changes.called, 1) eq(d.set_theme_type.called, 1) del dialog.activate_config_changes, dialog.deactivate_current_config del d.askyesno
def test_delete_custom_keys(self): eq = self.assertEqual d = self.page d.button_delete_custom_keys.state(('!disabled',)) yesno = d.askyesno = Func() dialog.deactivate_current_config = Func() dialog.activate_config_changes = Func() keyset_name = 'spam key set' idleConf.userCfg['keys'].SetOption(keyset_name, 'name', 'value') keyspage[keyset_name] = {'option': 'True'} # Force custom keyset. d.keyset_source.set(False) d.custom_name.set(keyset_name) # Cancel deletion. yesno.result = False d.button_delete_custom_keys.invoke() eq(yesno.called, 1) eq(keyspage[keyset_name], {'option': 'True'}) eq(idleConf.GetSectionList('user', 'keys'), ['spam key set']) eq(dialog.deactivate_current_config.called, 0) eq(dialog.activate_config_changes.called, 0) eq(d.set_keys_type.called, 0) # Confirm deletion. yesno.result = True d.button_delete_custom_keys.invoke() eq(yesno.called, 2) self.assertNotIn(keyset_name, keyspage) eq(idleConf.GetSectionList('user', 'keys'), []) eq(d.custom_keyset_on.state(), ('disabled',)) eq(d.custom_name.get(), '- no custom keys -') eq(dialog.deactivate_current_config.called, 1) eq(dialog.activate_config_changes.called, 1) eq(d.set_keys_type.called, 1) del dialog.activate_config_changes, dialog.deactivate_current_config del d.askyesno