mirror of
https://github.com/python/cpython.git
synced 2025-09-30 20:31:52 +00:00
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.
This commit is contained in:
parent
b350c22ebc
commit
bac7d3363b
3 changed files with 823 additions and 810 deletions
File diff suppressed because it is too large
Load diff
|
@ -21,14 +21,19 @@ testcfg = {
|
|||
'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.
|
||||
# For testing, record args in a list for comparison with expected.
|
||||
changes = []
|
||||
root = None
|
||||
configure = None
|
||||
|
||||
|
||||
class TestDialog(ConfigDialog):
|
||||
def AddChangedItem(self, *args):
|
||||
def add_changed_item(self, *args):
|
||||
changes.append(args)
|
||||
|
||||
|
||||
def setUpModule():
|
||||
global root, configure
|
||||
idleConf.userCfg = testcfg
|
||||
|
@ -49,40 +54,39 @@ def tearDownModule():
|
|||
|
||||
class FontTabTest(unittest.TestCase):
|
||||
|
||||
|
||||
def setUp(self):
|
||||
changes.clear()
|
||||
|
||||
def test_font(self):
|
||||
# Set values guaranteed not to be defaults.
|
||||
dfont = idleConf.GetFont(root, 'main', 'EditorWindow')
|
||||
dsize = str(dfont[1])
|
||||
dbold = dfont[2] == 'bold'
|
||||
configure.fontName.set('Test Font')
|
||||
default_font = idleConf.GetFont(root, 'main', 'EditorWindow')
|
||||
default_size = str(default_font[1])
|
||||
default_bold = default_font[2] == 'bold'
|
||||
configure.font_name.set('Test Font')
|
||||
expected = [
|
||||
('main', 'EditorWindow', 'font', 'Test Font'),
|
||||
('main', 'EditorWindow', 'font-size', dsize),
|
||||
('main', 'EditorWindow', 'font-bold', dbold)]
|
||||
('main', 'EditorWindow', 'font-size', default_size),
|
||||
('main', 'EditorWindow', 'font-bold', default_bold)]
|
||||
self.assertEqual(changes, expected)
|
||||
changes.clear()
|
||||
configure.fontSize.set(20)
|
||||
configure.font_size.set(20)
|
||||
expected = [
|
||||
('main', 'EditorWindow', 'font', 'Test Font'),
|
||||
('main', 'EditorWindow', 'font-size', '20'),
|
||||
('main', 'EditorWindow', 'font-bold', dbold)]
|
||||
('main', 'EditorWindow', 'font-bold', default_bold)]
|
||||
self.assertEqual(changes, expected)
|
||||
changes.clear()
|
||||
configure.fontBold.set(not dbold)
|
||||
configure.font_bold.set(not default_bold)
|
||||
expected = [
|
||||
('main', 'EditorWindow', 'font', 'Test Font'),
|
||||
('main', 'EditorWindow', 'font-size', '20'),
|
||||
('main', 'EditorWindow', 'font-bold', not dbold)]
|
||||
('main', 'EditorWindow', 'font-bold', not default_bold)]
|
||||
self.assertEqual(changes, expected)
|
||||
|
||||
#def test_sample(self): pass # TODO
|
||||
|
||||
def test_tabspace(self):
|
||||
configure.spaceNum.set(6)
|
||||
configure.space_num.set(6)
|
||||
self.assertEqual(changes, [('main', 'Indent', 'num-spaces', 6)])
|
||||
|
||||
|
||||
|
@ -106,19 +110,19 @@ class GeneralTest(unittest.TestCase):
|
|||
changes.clear()
|
||||
|
||||
def test_startup(self):
|
||||
configure.radioStartupEdit.invoke()
|
||||
configure.radio_startup_edit.invoke()
|
||||
self.assertEqual(changes,
|
||||
[('main', 'General', 'editor-on-startup', 1)])
|
||||
|
||||
def test_autosave(self):
|
||||
configure.radioSaveAuto.invoke()
|
||||
configure.radio_save_auto.invoke()
|
||||
self.assertEqual(changes, [('main', 'General', 'autosave', 1)])
|
||||
|
||||
def test_editor_size(self):
|
||||
configure.entryWinHeight.insert(0, '1')
|
||||
configure.entry_win_height.insert(0, '1')
|
||||
self.assertEqual(changes, [('main', 'EditorWindow', 'height', '140')])
|
||||
changes.clear()
|
||||
configure.entryWinWidth.insert(0, '1')
|
||||
configure.entry_win_width.insert(0, '1')
|
||||
self.assertEqual(changes, [('main', 'EditorWindow', 'width', '180')])
|
||||
|
||||
#def test_help_sources(self): pass # TODO
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
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.
|
Loading…
Add table
Add a link
Reference in a new issue