[Python-checkins] bpo-39388: IDLE: Fix bug when cancelling out of configdialog (GH-18068)

Miss Islington (bot) webhook-mailer at python.org
Sat Jan 25 04:17:59 EST 2020


https://github.com/python/cpython/commit/a23449285430081ea317cc1f203c80c410bbd8b9
commit: a23449285430081ea317cc1f203c80c410bbd8b9
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-01-25T01:17:54-08:00
summary:

bpo-39388: IDLE: Fix bug when cancelling out of configdialog (GH-18068)


Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>
(cherry picked from commit d0d9fa8c5e30aff71b6d5e8b2673396622f33270)

Co-authored-by: Cheryl Sabella <cheryl.sabella at gmail.com>

files:
A Misc/NEWS.d/next/IDLE/2020-01-25-02-26-45.bpo-39388.x4TQNh.rst
M Lib/idlelib/NEWS.txt
M Lib/idlelib/configdialog.py
M Lib/idlelib/idle_test/test_configdialog.py

diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 729d405116a3d..b7217335fe281 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -3,7 +3,9 @@ Released on 2019-12-16?
 ======================================
 
 
-bpo-39050: Make Settings dialog Help button work again.
+bpo-39388: Settings dialog Cancel button cancels pending changes.
+
+bpo-39050: Settings dialog Help button again displays help text.
 
 bpo-32989: Add tests for editor newline_and_indent_event method.
 Remove unneeded arguments and dead code from pyparse
diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py
index 0e007b516ea5e..2f95c9ccaa0c5 100644
--- a/Lib/idlelib/configdialog.py
+++ b/Lib/idlelib/configdialog.py
@@ -191,6 +191,7 @@ def cancel(self):
         Methods:
             destroy: inherited
         """
+        changes.clear()
         self.destroy()
 
     def destroy(self):
diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py
index 7c575d0e5992c..817a35217bf3c 100644
--- a/Lib/idlelib/idle_test/test_configdialog.py
+++ b/Lib/idlelib/idle_test/test_configdialog.py
@@ -47,17 +47,24 @@ def tearDownModule():
     root.destroy()
     root = dialog = None
 
-class ConfigDialogTest(unittest.TestCase):
 
-    def test_help(self):
+class DialogTest(unittest.TestCase):
+
+    @mock.patch(__name__+'.dialog.destroy', new_callable=Func)
+    def test_cancel(self, destroy):
+        changes['main']['something'] = 1
+        dialog.cancel()
+        self.assertEqual(changes['main'], {})
+        self.assertEqual(destroy.called, 1)
+
+    @mock.patch('idlelib.configdialog.view_text', new_callable=Func)
+    def test_help(self, view):
         dialog.note.select(dialog.keyspage)
-        saved = configdialog.view_text
-        view = configdialog.view_text = Func()
         dialog.help()
         s = view.kwds['contents']
-        self.assertTrue(s.startswith('When you click'))
-        self.assertTrue(s.endswith('a different name.\n'))
-        configdialog.view_text = saved
+        self.assertTrue(s.startswith('When you click') and
+                        s.endswith('a different name.\n'))
+
 
 class FontPageTest(unittest.TestCase):
     """Test that font widgets enable users to make font changes.
diff --git a/Misc/NEWS.d/next/IDLE/2020-01-25-02-26-45.bpo-39388.x4TQNh.rst b/Misc/NEWS.d/next/IDLE/2020-01-25-02-26-45.bpo-39388.x4TQNh.rst
new file mode 100644
index 0000000000000..42bbfb168c19d
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2020-01-25-02-26-45.bpo-39388.x4TQNh.rst
@@ -0,0 +1 @@
+IDLE Settings Cancel button now cancels pending changes



More information about the Python-checkins mailing list