[Python-checkins] [3.6] bpo-31287: IDLE - do not alter tkinter.messagebox in configdialog tests. (GH-3220) (#3221)

Terry Jan Reedy webhook-mailer at python.org
Sun Aug 27 17:14:22 EDT 2017


https://github.com/python/cpython/commit/7e248904cd5b3e658b1792deca1b82d873b2d120
commit: 7e248904cd5b3e658b1792deca1b82d873b2d120
branch: 3.6
author: Terry Jan Reedy <tjreedy at udel.edu>
committer: GitHub <noreply at github.com>
date: 2017-08-27T17:14:19-04:00
summary:

[3.6] bpo-31287: IDLE - do not alter tkinter.messagebox in configdialog tests. (GH-3220) (#3221)

(cherry picked from commit 3457f42)

files:
A Misc/NEWS.d/next/IDLE/2017-08-27-15-31-33.bpo-31287.aZERfI.rst
M Lib/idlelib/configdialog.py
M Lib/idlelib/idle_test/test_configdialog.py

diff --git a/Lib/idlelib/configdialog.py b/Lib/idlelib/configdialog.py
index ff7b638b51f..8afc9e6d692 100644
--- a/Lib/idlelib/configdialog.py
+++ b/Lib/idlelib/configdialog.py
@@ -18,7 +18,7 @@
                          Notebook, Radiobutton, Scrollbar, Style)
 import tkinter.colorchooser as tkColorChooser
 import tkinter.font as tkFont
-import tkinter.messagebox as tkMessageBox
+from tkinter import messagebox
 
 from idlelib.config import idleConf, ConfigChanges
 from idlelib.config_key import GetKeysDialog
@@ -1227,6 +1227,10 @@ def save_new(self, theme_name, theme):
             value = theme[element]
             idleConf.userCfg['highlight'].SetOption(theme_name, element, value)
 
+    def askyesno(self, *args, **kwargs):
+        # Make testing easier.  Could change implementation.
+        messagebox.askyesno(*args, **kwargs)
+
     def delete_custom(self):
         """Handle event to delete custom theme.
 
@@ -1251,7 +1255,7 @@ def delete_custom(self):
         """
         theme_name = self.custom_name.get()
         delmsg = 'Are you sure you wish to delete the theme %r ?'
-        if not tkMessageBox.askyesno(
+        if not self.askyesno(
                 'Delete Theme',  delmsg % theme_name, parent=self):
             return
         self.cd.deactivate_current_config()
@@ -1669,6 +1673,10 @@ def save_new_key_set(keyset_name, keyset):
             value = keyset[event]
             idleConf.userCfg['keys'].SetOption(keyset_name, event, value)
 
+    def askyesno(self, *args, **kwargs):
+        # Make testing easier.  Could change implementation.
+        messagebox.askyesno(*args, **kwargs)
+
     def delete_custom_keys(self):
         """Handle event to delete a custom key set.
 
@@ -1678,7 +1686,7 @@ def delete_custom_keys(self):
         """
         keyset_name = self.custom_name.get()
         delmsg = 'Are you sure you wish to delete the key set %r ?'
-        if not tkMessageBox.askyesno(
+        if not self.askyesno(
                 'Delete Key Set',  delmsg % keyset_name, parent=self):
             return
         self.cd.deactivate_current_config()
diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py
index c947da1866e..f116538faca 100644
--- a/Lib/idlelib/idle_test/test_configdialog.py
+++ b/Lib/idlelib/idle_test/test_configdialog.py
@@ -643,7 +643,7 @@ def test_delete_custom(self):
         eq = self.assertEqual
         d = self.page
         d.button_delete_custom.state(('!disabled',))
-        yesno = configdialog.tkMessageBox.askyesno = Func()
+        yesno = d.askyesno = Func()
         dialog.deactivate_current_config = Func()
         dialog.activate_config_changes = Func()
 
@@ -678,7 +678,7 @@ def test_delete_custom(self):
         eq(d.set_theme_type.called, 1)
 
         del dialog.activate_config_changes, dialog.deactivate_current_config
-        del configdialog.tkMessageBox.askyesno
+        del d.askyesno
 
 
 class KeysPageTest(unittest.TestCase):
@@ -1034,7 +1034,7 @@ def test_delete_custom_keys(self):
         eq = self.assertEqual
         d = self.page
         d.button_delete_custom_keys.state(('!disabled',))
-        yesno = configdialog.tkMessageBox.askyesno = Func()
+        yesno = d.askyesno = Func()
         dialog.deactivate_current_config = Func()
         dialog.activate_config_changes = Func()
 
@@ -1069,7 +1069,7 @@ def test_delete_custom_keys(self):
         eq(d.set_keys_type.called, 1)
 
         del dialog.activate_config_changes, dialog.deactivate_current_config
-        del configdialog.tkMessageBox.askyesno
+        del d.askyesno
 
 
 class GenPageTest(unittest.TestCase):
diff --git a/Misc/NEWS.d/next/IDLE/2017-08-27-15-31-33.bpo-31287.aZERfI.rst b/Misc/NEWS.d/next/IDLE/2017-08-27-15-31-33.bpo-31287.aZERfI.rst
new file mode 100644
index 00000000000..9cd55573f87
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2017-08-27-15-31-33.bpo-31287.aZERfI.rst
@@ -0,0 +1 @@
+IDLE - Do not modify tkinter.message in test_configdialog.



More information about the Python-checkins mailing list