Example #1
0
    def test_builtin_name(self):
        eq = self.assertEqual
        d = self.page
        item_list = ['edit Classic', 'edit Dark', 'edit New']

        # Not in old_themes, defaults name to first item.
        editConf.SetOption('main', 'Theme', 'name', 'spam')
        d.builtinlist.SetMenu(item_list, 'edit Dark')
        eq(mainpage, {'Theme': {'name': 'edit Classic', 'name2': 'edit Dark'}})
        eq(d.theme_message['text'], 'New theme, see Help')
        eq(d.paint_theme_sample.called, 1)

        # Not in old themes - uses name2.
        changes.clear()
        editConf.SetOption('main', 'Theme', 'name', 'edit New')
        d.builtinlist.SetMenu(item_list, 'edit Dark')
        eq(mainpage, {'Theme': {'name2': 'edit Dark'}})
        eq(d.theme_message['text'], 'New theme, see Help')
        eq(d.paint_theme_sample.called, 2)

        # Builtin name in old_themes.
        changes.clear()
        d.builtinlist.SetMenu(item_list, 'edit Classic')
        eq(mainpage, {'Theme': {'name': 'edit Classic', 'name2': ''}})
        eq(d.theme_message['text'], '')
        eq(d.paint_theme_sample.called, 3)
Example #2
0
 def test_startup(self):
     d = self.page
     d.startup_editor_on.invoke()
     self.assertEqual(mainpage, {'General': {'editor-on-startup': '1'}})
     changes.clear()
     d.startup_shell_on.invoke()
     self.assertEqual(mainpage, {'General': {'editor-on-startup': '0'}})
Example #3
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 editConf.GetSectionList('user', 'keys'):
         editConf.userCfg['keys'].remove_section(section)
     changes.clear()
     d.set_keys_type.called = 0
     d.load_keys_list.called = 0
Example #4
0
def tearDownModule():
    global root, dialog
    editConf.userCfg = usercfg
    tracers.detach()
    tracers.clear()
    changes.clear()
    root.update_edittasks()
    root.destroy()
    root = dialog = None
Example #5
0
 def test_editor_size(self):
     d = self.page
     d.win_height_int.delete(0, 'end')
     d.win_height_int.insert(0, '11')
     self.assertEqual(mainpage, {'EditorWindow': {'height': '11'}})
     changes.clear()
     d.win_width_int.delete(0, 'end')
     d.win_width_int.insert(0, '11')
     self.assertEqual(mainpage, {'EditorWindow': {'width': '11'}})
Example #6
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 editConf.GetSectionList('user', 'highlight'):
         editConf.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
Example #7
0
 def test_make_callback(self):
     cb = self.tracers.make_callback(self.iv, ('main', 'section', 'option'))
     self.assertTrue(callable(cb))
     self.iv.set(42)
     # Not attached, so set didn't invoke the callback.
     self.assertNotIn('section', changes['main'])
     # Invoke callback manually.
     cb()
     self.assertIn('section', changes['main'])
     self.assertEqual(changes['main']['section']['option'], '42')
     changes.clear()
Example #8
0
 def test_parenmatch(self):
     d = self.page
     eq = self.assertEqual
     d.paren_style_type['menu'].invoke(0)
     eq(extpage, {'ParenMatch': {'style': 'opener'}})
     changes.clear()
     d.paren_flash_time.delete(0, 'end')
     d.paren_flash_time.insert(0, '11')
     eq(extpage, {'ParenMatch': {'flash-delay': '11'}})
     changes.clear()
     d.bell_on.invoke()
     eq(extpage, {'ParenMatch': {'bell': 'False'}})
Example #9
0
    def test_custom_name(self):
        d = self.page

        # If no selections, doesn't get added.
        d.customlist.SetMenu([], '- no custom keys -')
        self.assertNotIn('Keys', mainpage)
        self.assertEqual(d.load_keys_list.called, 0)

        # Custom name selected.
        changes.clear()
        d.customlist.SetMenu(['a', 'b', 'c'], 'c')
        self.assertEqual(mainpage, {'Keys': {'name': 'c'}})
        self.assertEqual(d.load_keys_list.called, 1)
Example #10
0
    def test_custom_name(self):
        d = self.page

        # If no selections, doesn't get added.
        d.customlist.SetMenu([], '- no custom themes -')
        self.assertNotIn('Theme', mainpage)
        self.assertEqual(d.paint_theme_sample.called, 0)

        # Custom name selected.
        changes.clear()
        d.customlist.SetMenu(['a', 'b', 'c'], 'c')
        self.assertEqual(mainpage, {'Theme': {'name': 'c'}})
        self.assertEqual(d.paint_theme_sample.called, 1)
Example #11
0
    def test_font_set(self):
        # Test that setting a font Variable results in 3 provisional
        # change entries and a call to set_samples. Use values sure to
        # not be defaults.

        default_font = editConf.GetFont(root, 'main', 'EditorWindow')
        default_size = str(default_font[1])
        default_bold = default_font[2] == 'bold'
        d = self.page
        d.font_size.set(default_size)
        d.font_bold.set(default_bold)
        d.set_samples.called = 0

        d.font_name.set('Test Font')
        expected = {
            'EditorWindow': {
                'font': 'Test Font',
                'font-size': default_size,
                'font-bold': str(default_bold)
            }
        }
        self.assertEqual(mainpage, expected)
        self.assertEqual(d.set_samples.called, 1)
        changes.clear()

        d.font_size.set('20')
        expected = {
            'EditorWindow': {
                'font': 'Test Font',
                'font-size': '20',
                'font-bold': str(default_bold)
            }
        }
        self.assertEqual(mainpage, expected)
        self.assertEqual(d.set_samples.called, 2)
        changes.clear()

        d.font_bold.set(not default_bold)
        expected = {
            'EditorWindow': {
                'font': 'Test Font',
                'font-size': '20',
                'font-bold': str(not default_bold)
            }
        }
        self.assertEqual(mainpage, expected)
        self.assertEqual(d.set_samples.called, 3)
Example #12
0
    def test_keyset_source(self):
        eq = self.assertEqual
        d = self.page
        # Test these separately.
        d.var_changed_builtin_name = Func()
        d.var_changed_custom_name = Func()
        # Builtin selected.
        d.builtin_keyset_on.invoke()
        eq(mainpage, {'Keys': {'default': 'True'}})
        eq(d.var_changed_builtin_name.called, 1)
        eq(d.var_changed_custom_name.called, 0)
        changes.clear()

        # Custom selected.
        d.custom_keyset_on.state(('!disabled', ))
        d.custom_keyset_on.invoke()
        self.assertEqual(mainpage, {'Keys': {'default': 'False'}})
        eq(d.var_changed_builtin_name.called, 1)
        eq(d.var_changed_custom_name.called, 1)
        del d.var_changed_builtin_name, d.var_changed_custom_name
Example #13
0
    def test_builtin_name(self):
        eq = self.assertEqual
        d = self.page
        editConf.userCfg['main'].remove_section('Keys')
        item_list = [
            'edit Classic Windows', 'edit Classic OSX', 'edit Modern UNIX'
        ]

        # Not in old_keys, defaults name to first item.
        d.builtinlist.SetMenu(item_list, 'edit Modern UNIX')
        eq(mainpage, {
            'Keys': {
                'name': 'edit Classic Windows',
                'name2': 'edit Modern UNIX'
            }
        })
        eq(d.keys_message['text'], 'New key set, see Help')
        eq(d.load_keys_list.called, 1)
        eq(d.load_keys_list.args, ('edit Modern UNIX', ))

        # Not in old keys - uses name2.
        changes.clear()
        editConf.SetOption('main', 'Keys', 'name', 'edit Classic Unix')
        d.builtinlist.SetMenu(item_list, 'edit Modern UNIX')
        eq(mainpage, {'Keys': {'name2': 'edit Modern UNIX'}})
        eq(d.keys_message['text'], 'New key set, see Help')
        eq(d.load_keys_list.called, 2)
        eq(d.load_keys_list.args, ('edit Modern UNIX', ))

        # Builtin name in old_keys.
        changes.clear()
        d.builtinlist.SetMenu(item_list, 'edit Classic OSX')
        eq(mainpage, {'Keys': {'name': 'edit Classic OSX', 'name2': ''}})
        eq(d.keys_message['text'], '')
        eq(d.load_keys_list.called, 3)
        eq(d.load_keys_list.args, ('edit Classic OSX', ))
Example #14
0
 def setUp(self):
     changes.clear()
Example #15
0
 def test_indent_scale(self):
     d = self.page
     changes.clear()
     d.indent_scale.set(20)
     self.assertEqual(d.space_num.get(), 16)
     self.assertEqual(mainpage, {'Indent': {'num-spaces': '16'}})