Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revise configdialog tests to match other changes. All pass.
  • Loading branch information
terryjreedy committed Jul 7, 2017
commit 6e6f4ee5277f19f9fb7c401f916558291abd4bc9
57 changes: 25 additions & 32 deletions Lib/idlelib/idle_test/test_configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Half the class creates dialog, half works with user customizations.
Coverage: 46% just by creating dialog, 56% with current tests.
"""
from idlelib.configdialog import ConfigDialog, idleConf # test import
from idlelib.configdialog import ConfigDialog, idleConf, changes
from test.support import requires
requires('gui')
from tkinter import Tk
Expand All @@ -21,18 +21,14 @@
'extensions': config.IdleUserConfParser(''),
}

# 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
mainpage = changes['main']
highpage = changes['highlight']
keyspage = changes['keys']


class TestDialog(ConfigDialog):
def add_changed_item(self, *args):
changes.append(args)

class TestDialog(ConfigDialog): pass # Delete?


def setUpModule():
global root, configure
Expand All @@ -44,7 +40,7 @@ def setUpModule():

def tearDownModule():
global root, configure
idleConf.userCfg = testcfg
idleConf.userCfg = usercfg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should rebase/merge master branch since this changed has been merged into via PR #2606.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though maybe I branched after fetching that. Anyway, I fetched again, pushed master to origin, and
ran <git merge origin/master>, from the devguide, which has worked before. and pushed.
... Above -+ is gone from new diff.

configure.remove_var_callbacks()
del configure
root.update_idletasks()
Expand All @@ -63,31 +59,28 @@ def test_font(self):
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', default_size),
('main', 'EditorWindow', 'font-bold', default_bold)]
self.assertEqual(changes, expected)
expected = {'EditorWindow': {'font': 'Test Font',
'font-size': default_size,
'font-bold': str(default_bold)}}
self.assertEqual(mainpage, expected)
changes.clear()
configure.font_size.set(20)
expected = [
('main', 'EditorWindow', 'font', 'Test Font'),
('main', 'EditorWindow', 'font-size', '20'),
('main', 'EditorWindow', 'font-bold', default_bold)]
self.assertEqual(changes, expected)
expected = {'EditorWindow': {'font': 'Test Font',
'font-size': '20',
'font-bold': str(default_bold)}}
self.assertEqual(mainpage, expected)
changes.clear()
configure.font_bold.set(not default_bold)
expected = [
('main', 'EditorWindow', 'font', 'Test Font'),
('main', 'EditorWindow', 'font-size', '20'),
('main', 'EditorWindow', 'font-bold', not default_bold)]
self.assertEqual(changes, expected)
expected = {'EditorWindow': {'font': 'Test Font',
'font-size': '20',
'font-bold': str(not default_bold)}}
self.assertEqual(mainpage, expected)

#def test_sample(self): pass # TODO

def test_tabspace(self):
configure.space_num.set(6)
self.assertEqual(changes, [('main', 'Indent', 'num-spaces', 6)])
self.assertEqual(mainpage, {'Indent': {'num-spaces': '6'}})


class HighlightTest(unittest.TestCase):
Expand All @@ -111,19 +104,19 @@ def setUp(self):

def test_startup(self):
configure.radio_startup_edit.invoke()
self.assertEqual(changes,
[('main', 'General', 'editor-on-startup', 1)])
self.assertEqual(mainpage,
{'General': {'editor-on-startup': '1'}})

def test_autosave(self):
configure.radio_save_auto.invoke()
self.assertEqual(changes, [('main', 'General', 'autosave', 1)])
self.assertEqual(mainpage, {'General': {'autosave': '1'}})

def test_editor_size(self):
configure.entry_win_height.insert(0, '1')
self.assertEqual(changes, [('main', 'EditorWindow', 'height', '140')])
self.assertEqual(mainpage, {'EditorWindow': {'height': '140'}})
changes.clear()
configure.entry_win_width.insert(0, '1')
self.assertEqual(changes, [('main', 'EditorWindow', 'width', '180')])
self.assertEqual(mainpage, {'EditorWindow': {'width': '180'}})

#def test_help_sources(self): pass # TODO

Expand Down