MCPcopy Index your code
hub / github.com/python/cpython / test_delete_custom

Method test_delete_custom

Lib/idlelib/idle_test/test_configdialog.py:711–768  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

709 page.paint_theme_sample = Func()
710
711 def test_delete_custom(self):
712 eq = self.assertEqual
713 d = self.page
714 d.button_delete_custom.state(('!disabled',))
715 yesno = d.askyesno = Func()
716 dialog.deactivate_current_config = Func()
717 dialog.activate_config_changes = Func()
718
719 theme_name = 'spam theme'
720 idleConf.userCfg['highlight'].SetOption(theme_name, 'name', 'value')
721 highpage[theme_name] = {'option': 'True'}
722
723 theme_name2 = 'other theme'
724 idleConf.userCfg['highlight'].SetOption(theme_name2, 'name', 'value')
725 highpage[theme_name2] = {'option': 'False'}
726
727 # Force custom theme.
728 d.custom_theme_on.state(('!disabled',))
729 d.custom_theme_on.invoke()
730 d.custom_name.set(theme_name)
731
732 # Cancel deletion.
733 yesno.result = False
734 d.button_delete_custom.invoke()
735 eq(yesno.called, 1)
736 eq(highpage[theme_name], {'option': 'True'})
737 eq(idleConf.GetSectionList('user', 'highlight'), [theme_name, theme_name2])
738 eq(dialog.deactivate_current_config.called, 0)
739 eq(dialog.activate_config_changes.called, 0)
740 eq(d.set_theme_type.called, 0)
741
742 # Confirm deletion.
743 yesno.result = True
744 d.button_delete_custom.invoke()
745 eq(yesno.called, 2)
746 self.assertNotIn(theme_name, highpage)
747 eq(idleConf.GetSectionList('user', 'highlight'), [theme_name2])
748 eq(d.custom_theme_on.state(), ())
749 eq(d.custom_name.get(), theme_name2)
750 eq(dialog.deactivate_current_config.called, 1)
751 eq(dialog.activate_config_changes.called, 1)
752 eq(d.set_theme_type.called, 1)
753
754 # Confirm deletion of second theme - empties list.
755 d.custom_name.set(theme_name2)
756 yesno.result = True
757 d.button_delete_custom.invoke()
758 eq(yesno.called, 3)
759 self.assertNotIn(theme_name, highpage)
760 eq(idleConf.GetSectionList('user', 'highlight'), [])
761 eq(d.custom_theme_on.state(), ('disabled',))
762 eq(d.custom_name.get(), '- no custom themes -')
763 eq(dialog.deactivate_current_config.called, 2)
764 eq(dialog.activate_config_changes.called, 2)
765 eq(d.set_theme_type.called, 2)
766
767 del dialog.activate_config_changes, dialog.deactivate_current_config
768 del d.askyesno

Callers

nothing calls this directly

Calls 9

FuncClass · 0.90
eqFunction · 0.85
GetSectionListMethod · 0.80
assertNotInMethod · 0.80
stateMethod · 0.45
SetOptionMethod · 0.45
invokeMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected