2020-12-19 06:17:08 -04:00
|
|
|
import unittest
|
|
|
|
import tkinter
|
2021-10-13 13:12:48 -03:00
|
|
|
from test.support import requires, swap_attr
|
2022-06-22 17:23:37 -03:00
|
|
|
from test.test_tkinter.support import AbstractDefaultRootTest
|
2020-12-19 06:17:08 -04:00
|
|
|
from tkinter.simpledialog import Dialog, askinteger
|
|
|
|
|
|
|
|
requires('gui')
|
|
|
|
|
|
|
|
|
|
|
|
class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
|
|
|
|
|
|
|
|
def test_askinteger(self):
|
2020-12-25 14:19:20 -04:00
|
|
|
@staticmethod
|
|
|
|
def mock_wait_window(w):
|
|
|
|
nonlocal ismapped
|
|
|
|
ismapped = w.master.winfo_ismapped()
|
|
|
|
w.destroy()
|
|
|
|
|
|
|
|
with swap_attr(Dialog, 'wait_window', mock_wait_window):
|
|
|
|
ismapped = None
|
|
|
|
askinteger("Go To Line", "Line number")
|
|
|
|
self.assertEqual(ismapped, False)
|
|
|
|
|
|
|
|
root = tkinter.Tk()
|
|
|
|
ismapped = None
|
2020-12-19 06:17:08 -04:00
|
|
|
askinteger("Go To Line", "Line number")
|
2020-12-25 14:19:20 -04:00
|
|
|
self.assertEqual(ismapped, True)
|
|
|
|
root.destroy()
|
|
|
|
|
|
|
|
tkinter.NoDefaultRoot()
|
|
|
|
self.assertRaises(RuntimeError, askinteger, "Go To Line", "Line number")
|
2020-12-19 06:17:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-10-13 13:12:48 -03:00
|
|
|
unittest.main()
|