Browse Source
bpo-42630: Improve error reporting in Tkinter for absent default root (GH-23781)
bpo-42630: Improve error reporting in Tkinter for absent default root (GH-23781)
* Tkinter functions and constructors which need a default root window raise now RuntimeError with descriptive message instead of obscure AttributeError or NameError if it is not created yet or cannot be created automatically. * Add tests for all functions which use default root window. * Fix import in the pynche script.pull/23857/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 315 additions and 87 deletions
-
4Lib/idlelib/pyshell.py
-
2Lib/test/test_idle.py
-
51Lib/tkinter/__init__.py
-
4Lib/tkinter/commondialog.py
-
6Lib/tkinter/font.py
-
19Lib/tkinter/simpledialog.py
-
27Lib/tkinter/test/support.py
-
34Lib/tkinter/test/test_tkinter/test_font.py
-
45Lib/tkinter/test/test_tkinter/test_images.py
-
82Lib/tkinter/test/test_tkinter/test_misc.py
-
25Lib/tkinter/test/test_tkinter/test_simpledialog.py
-
17Lib/tkinter/test/test_tkinter/test_variables.py
-
14Lib/tkinter/test/test_tkinter/test_widgets.py
-
26Lib/tkinter/test/test_ttk/test_extensions.py
-
14Lib/tkinter/test/test_ttk/test_widgets.py
-
9Lib/tkinter/tix.py
-
7Lib/tkinter/ttk.py
-
4Misc/NEWS.d/next/Library/2020-12-15-17-51-27.bpo-42630.jf4jBl.rst
-
12Tools/pynche/PyncheWidget.py
@ -0,0 +1,25 @@ |
|||
import unittest |
|||
import tkinter |
|||
from test.support import requires, run_unittest, swap_attr |
|||
from tkinter.test.support import AbstractDefaultRootTest |
|||
from tkinter.simpledialog import Dialog, askinteger |
|||
|
|||
requires('gui') |
|||
|
|||
|
|||
class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase): |
|||
|
|||
def test_askinteger(self): |
|||
self.assertRaises(RuntimeError, askinteger, "Go To Line", "Line number") |
|||
root = tkinter.Tk() |
|||
with swap_attr(Dialog, 'wait_window', lambda self, w: w.destroy()): |
|||
askinteger("Go To Line", "Line number") |
|||
root.destroy() |
|||
tkinter.NoDefaultRoot() |
|||
self.assertRaises(RuntimeError, askinteger, "Go To Line", "Line number") |
|||
|
|||
|
|||
tests_gui = (DefaultRootTest,) |
|||
|
|||
if __name__ == "__main__": |
|||
run_unittest(*tests_gui) |
|||
@ -0,0 +1,4 @@ |
|||
:mod:`tkinter` functions and constructors which need a default root window |
|||
raise now :exc:`RuntimeError` with descriptive message instead of obscure |
|||
:exc:`AttributeError` or :exc:`NameError` if it is not created yet or cannot |
|||
be created automatically. |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue