Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions Lib/test/test_tkinter/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,48 @@ def test_tk_bisque(self):
self.assertEqual(root['background'], '#ffe4c4')
self.assertRaises(TypeError, root.tk_bisque, 'x')

def test_wait_variable(self):
var = tkinter.StringVar(self.root)
self.assertEqual(self.root.waitvar, self.root.wait_variable)
self.root.after(1, var.set, 'done')
self.root.wait_variable(var) # Returns once the variable is set.
self.assertEqual(var.get(), 'done')

def test_wait_window(self):
top = tkinter.Toplevel(self.root)
self.root.after(1, top.destroy)
self.root.wait_window(top) # Returns once the window is destroyed.
self.assertFalse(top.winfo_exists())

def test_tk_focusFollowsMouse(self):
self.root.tk_focusFollowsMouse() # No exception.

def test_selection_handle(self):
f = tkinter.Frame(self.root)
def handler(offset, length):
return 'PAYLOAD'[int(offset):int(offset) + int(length)]
f.selection_handle(handler)
f.selection_own()
self.assertEqual(f.selection_get(), 'PAYLOAD')

def test_grab_set_global(self):
# A successful global grab directs all events on the display to this
# application, so only the error paths are tested here.
self.assertRaises(TypeError, self.root.grab_set_global, 'extra')
with self.subTest('non-viewable window'):
if self.root._windowingsystem != 'x11':
# Grabbing a non-viewable window fails only on X11; elsewhere
# it would actually grab the whole display.
self.skipTest('only X11 fails the grab')
f = tkinter.Frame(self.root) # not yet viewable
self.assertRaisesRegex(TclError, 'grab failed', f.grab_set_global)

def test_send(self):
if self.root._windowingsystem != 'x11':
self.skipTest('send is only supported on X11')
self.assertRaisesRegex(TclError, 'no application named',
self.root.send, 'no_such_interp_xyzzy', 'set x 1')

def test_event_repr_defaults(self):
e = tkinter.Event()
e.serial = 12345
Expand Down Expand Up @@ -934,6 +976,35 @@ def test_wm_iconname(self):
t.iconname('Icon')
self.assertIn(t.iconname(), ('Icon', ''))

def test_wm_iconposition(self):
t = tkinter.Toplevel(self.root)
t.wm_iconposition(3, 4) # An X11 hint; may be a no-op elsewhere.
if t._windowingsystem == 'x11':
self.assertEqual(t.wm_iconposition(), (3, 4))

def test_wm_iconmask_iconwindow(self):
if self.root._windowingsystem != 'x11':
self.skipTest('iconmask and iconwindow are X11-specific')
t = tkinter.Toplevel(self.root)
t.wm_iconmask('gray50') # No exception.
icon = tkinter.Toplevel(self.root)
t.wm_iconwindow(icon)
self.assertEqual(str(t.wm_iconwindow()), str(icon))

def test_wm_colormapwindows(self):
if self.root._windowingsystem != 'x11':
self.skipTest('colormapwindows is X11-specific')
t = tkinter.Toplevel(self.root)
self.assertEqual(t.wm_colormapwindows(), [])
f = tkinter.Frame(t)
t.wm_colormapwindows(f)
self.assertEqual([str(w) for w in t.wm_colormapwindows()], [str(f)])

def test_wm_manage_forget(self):
f = tkinter.Frame(self.root)
self.root.wm_manage(f) # Make the frame a top-level window.
self.root.wm_forget(f) # Revert it; no exception either way.

def test_wm_client_command(self):
t = tkinter.Toplevel(self.root)
t.client('myhost')
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_tkinter/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ def test_window_configure(self):
self.assertIsInstance(cnf, dict)
self.assertIn('stretch', cnf)
self.assertRaises(TclError, text.window_cget, '1.1', 'spam')
self.assertEqual(text.window_config, text.window_configure)
button.destroy()

def test_peer(self):
Expand Down Expand Up @@ -585,6 +586,11 @@ def test_see(self):
self.assertRaises(TypeError, text.see)
self.assertRaises(TypeError, text.see, '1.0', '2.0')

# yview_pickplace is a deprecated way to make an index visible.
text.yview_pickplace('1.0')
text.update()
self.assertIsNotNone(text.bbox('1.0'))

def test_search(self):
text = self.text

Expand Down
Loading