mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Refresh the IDLE, Tkinter and turtle family through update_lib, including the direct canonical text-only helper and image fixture dependencies. Preserve capability/display guards without changing native Tk support. Assisted-by: OpenAI Codex:model-version-unavailable
38 lines
1.2 KiB
Python
Vendored
38 lines
1.2 KiB
Python
Vendored
import unittest
|
|
import tkinter
|
|
from test.support import requires, swap_attr
|
|
from test.test_tkinter.support import setUpModule # noqa: F401
|
|
from test.test_tkinter.support import AbstractDefaultRootTest
|
|
from tkinter.commondialog import Dialog
|
|
from tkinter.messagebox import showinfo
|
|
|
|
requires('gui')
|
|
|
|
|
|
class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
|
|
|
|
def test_showinfo(self):
|
|
def test_callback(dialog, master):
|
|
nonlocal ismapped
|
|
master.update()
|
|
ismapped = master.winfo_ismapped()
|
|
raise ZeroDivisionError
|
|
|
|
with swap_attr(Dialog, '_test_callback', test_callback):
|
|
ismapped = None
|
|
self.assertRaises(ZeroDivisionError, showinfo, "Spam", "Egg Information")
|
|
self.assertEqual(ismapped, False)
|
|
|
|
root = tkinter.Tk()
|
|
ismapped = None
|
|
self.assertRaises(ZeroDivisionError, showinfo, "Spam", "Egg Information")
|
|
self.assertEqual(ismapped, True)
|
|
root.destroy()
|
|
|
|
tkinter.NoDefaultRoot()
|
|
self.assertRaises(RuntimeError, showinfo, "Spam", "Egg Information")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|