Kaydet (Commit) bac7d336 authored tarafından csabella's avatar csabella Kaydeden (comit) terryjreedy

bpo-30728: IDLE: Refactor configdialog to PEP8 names (#2307)

Also, change '*' in the tkinter import to an explicit list of names.
Patch by Cheryl Sabella.
üst b350c22e
This diff is collapsed.
...@@ -21,14 +21,19 @@ testcfg = { ...@@ -21,14 +21,19 @@ testcfg = {
'extensions': config.IdleUserConfParser(''), 'extensions': config.IdleUserConfParser(''),
} }
# ConfigDialog.changedItems is a 3-level hierarchical dictionary of # ConfigDialog.changed_items is a 3-level hierarchical dictionary of
# pending changes that mirrors the multilevel user config dict. # pending changes that mirrors the multilevel user config dict.
# For testing, record args in a list for comparison with expected. # For testing, record args in a list for comparison with expected.
changes = [] changes = []
root = None
configure = None
class TestDialog(ConfigDialog): class TestDialog(ConfigDialog):
def AddChangedItem(self, *args): def add_changed_item(self, *args):
changes.append(args) changes.append(args)
def setUpModule(): def setUpModule():
global root, configure global root, configure
idleConf.userCfg = testcfg idleConf.userCfg = testcfg
...@@ -49,40 +54,39 @@ def tearDownModule(): ...@@ -49,40 +54,39 @@ def tearDownModule():
class FontTabTest(unittest.TestCase): class FontTabTest(unittest.TestCase):
def setUp(self): def setUp(self):
changes.clear() changes.clear()
def test_font(self): def test_font(self):
# Set values guaranteed not to be defaults. # Set values guaranteed not to be defaults.
dfont = idleConf.GetFont(root, 'main', 'EditorWindow') default_font = idleConf.GetFont(root, 'main', 'EditorWindow')
dsize = str(dfont[1]) default_size = str(default_font[1])
dbold = dfont[2] == 'bold' default_bold = default_font[2] == 'bold'
configure.fontName.set('Test Font') configure.font_name.set('Test Font')
expected = [ expected = [
('main', 'EditorWindow', 'font', 'Test Font'), ('main', 'EditorWindow', 'font', 'Test Font'),
('main', 'EditorWindow', 'font-size', dsize), ('main', 'EditorWindow', 'font-size', default_size),
('main', 'EditorWindow', 'font-bold', dbold)] ('main', 'EditorWindow', 'font-bold', default_bold)]
self.assertEqual(changes, expected) self.assertEqual(changes, expected)
changes.clear() changes.clear()
configure.fontSize.set(20) configure.font_size.set(20)
expected = [ expected = [
('main', 'EditorWindow', 'font', 'Test Font'), ('main', 'EditorWindow', 'font', 'Test Font'),
('main', 'EditorWindow', 'font-size', '20'), ('main', 'EditorWindow', 'font-size', '20'),
('main', 'EditorWindow', 'font-bold', dbold)] ('main', 'EditorWindow', 'font-bold', default_bold)]
self.assertEqual(changes, expected) self.assertEqual(changes, expected)
changes.clear() changes.clear()
configure.fontBold.set(not dbold) configure.font_bold.set(not default_bold)
expected = [ expected = [
('main', 'EditorWindow', 'font', 'Test Font'), ('main', 'EditorWindow', 'font', 'Test Font'),
('main', 'EditorWindow', 'font-size', '20'), ('main', 'EditorWindow', 'font-size', '20'),
('main', 'EditorWindow', 'font-bold', not dbold)] ('main', 'EditorWindow', 'font-bold', not default_bold)]
self.assertEqual(changes, expected) self.assertEqual(changes, expected)
#def test_sample(self): pass # TODO #def test_sample(self): pass # TODO
def test_tabspace(self): def test_tabspace(self):
configure.spaceNum.set(6) configure.space_num.set(6)
self.assertEqual(changes, [('main', 'Indent', 'num-spaces', 6)]) self.assertEqual(changes, [('main', 'Indent', 'num-spaces', 6)])
...@@ -106,19 +110,19 @@ class GeneralTest(unittest.TestCase): ...@@ -106,19 +110,19 @@ class GeneralTest(unittest.TestCase):
changes.clear() changes.clear()
def test_startup(self): def test_startup(self):
configure.radioStartupEdit.invoke() configure.radio_startup_edit.invoke()
self.assertEqual(changes, self.assertEqual(changes,
[('main', 'General', 'editor-on-startup', 1)]) [('main', 'General', 'editor-on-startup', 1)])
def test_autosave(self): def test_autosave(self):
configure.radioSaveAuto.invoke() configure.radio_save_auto.invoke()
self.assertEqual(changes, [('main', 'General', 'autosave', 1)]) self.assertEqual(changes, [('main', 'General', 'autosave', 1)])
def test_editor_size(self): def test_editor_size(self):
configure.entryWinHeight.insert(0, '1') configure.entry_win_height.insert(0, '1')
self.assertEqual(changes, [('main', 'EditorWindow', 'height', '140')]) self.assertEqual(changes, [('main', 'EditorWindow', 'height', '140')])
changes.clear() changes.clear()
configure.entryWinWidth.insert(0, '1') configure.entry_win_width.insert(0, '1')
self.assertEqual(changes, [('main', 'EditorWindow', 'width', '180')]) self.assertEqual(changes, [('main', 'EditorWindow', 'width', '180')])
#def test_help_sources(self): pass # TODO #def test_help_sources(self): pass # TODO
......
Review and change idlelib.configdialog names.
Lowercase method and attribute names.
Replace 'colour' with 'color', expand overly cryptic names, delete unneeded underscores.
Replace ``import *`` with specific imports. Patches by Cheryl Sabella.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment