Skip to content

Commit a234492

Browse files
bpo-39388: IDLE: Fix bug when cancelling out of configdialog (GH-18068)
Co-authored-by: Terry Jan Reedy <[email protected]> (cherry picked from commit d0d9fa8) Co-authored-by: Cheryl Sabella <[email protected]>
1 parent ea4a61f commit a234492

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

Lib/idlelib/NEWS.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ Released on 2019-12-16?
33
======================================
44

55

6-
bpo-39050: Make Settings dialog Help button work again.
6+
bpo-39388: Settings dialog Cancel button cancels pending changes.
7+
8+
bpo-39050: Settings dialog Help button again displays help text.
79

810
bpo-32989: Add tests for editor newline_and_indent_event method.
911
Remove unneeded arguments and dead code from pyparse

Lib/idlelib/configdialog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def cancel(self):
191191
Methods:
192192
destroy: inherited
193193
"""
194+
changes.clear()
194195
self.destroy()
195196

196197
def destroy(self):

Lib/idlelib/idle_test/test_configdialog.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,24 @@ def tearDownModule():
4747
root.destroy()
4848
root = dialog = None
4949

50-
class ConfigDialogTest(unittest.TestCase):
5150

52-
def test_help(self):
51+
class DialogTest(unittest.TestCase):
52+
53+
@mock.patch(__name__+'.dialog.destroy', new_callable=Func)
54+
def test_cancel(self, destroy):
55+
changes['main']['something'] = 1
56+
dialog.cancel()
57+
self.assertEqual(changes['main'], {})
58+
self.assertEqual(destroy.called, 1)
59+
60+
@mock.patch('idlelib.configdialog.view_text', new_callable=Func)
61+
def test_help(self, view):
5362
dialog.note.select(dialog.keyspage)
54-
saved = configdialog.view_text
55-
view = configdialog.view_text = Func()
5663
dialog.help()
5764
s = view.kwds['contents']
58-
self.assertTrue(s.startswith('When you click'))
59-
self.assertTrue(s.endswith('a different name.\n'))
60-
configdialog.view_text = saved
65+
self.assertTrue(s.startswith('When you click') and
66+
s.endswith('a different name.\n'))
67+
6168

6269
class FontPageTest(unittest.TestCase):
6370
"""Test that font widgets enable users to make font changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IDLE Settings Cancel button now cancels pending changes

0 commit comments

Comments
 (0)