MCPcopy Index your code
hub / github.com/python/cpython / test_after_idle

Method test_after_idle

Lib/test/test_tkinter/test_misc.py:181–217  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

179 self.assertEqual(count, 54)
180
181 def test_after_idle(self):
182 root = self.root
183
184 def callback(start=0, step=1, *, end=0):
185 nonlocal count
186 count = start + step + end
187
188 # Set up with callback with no args.
189 count = 0
190 idle1 = root.after_idle(callback)
191 self.assertIn(idle1, root.tk.call('after', 'info'))
192 (script, _) = root.tk.splitlist(root.tk.call('after', 'info', idle1))
193 root.update_idletasks() # Process all pending events.
194 self.assertEqual(count, 1)
195 with self.assertRaises(tkinter.TclError):
196 root.tk.call(script)
197
198 # Set up with callback with args.
199 count = 0
200 idle1 = root.after_idle(callback, 42, 11)
201 root.update_idletasks() # Process all pending events.
202 self.assertEqual(count, 53)
203
204 # Cancel before called.
205 idle1 = root.after_idle(callback)
206 self.assertIn(idle1, root.tk.call('after', 'info'))
207 (script, _) = root.tk.splitlist(root.tk.call('after', 'info', idle1))
208 root.after_cancel(idle1) # Cancel this event.
209 self.assertEqual(count, 53)
210 with self.assertRaises(tkinter.TclError):
211 root.tk.call(script)
212
213 # Set up with callback with keyword args.
214 count = 0
215 idle1 = root.after_idle(callback, 42, step=11, end=1)
216 root.update() # Process all pending events.
217 self.assertEqual(count, 54)
218
219 def test_after_cancel(self):
220 root = self.root

Callers

nothing calls this directly

Calls 9

after_idleMethod · 0.80
assertInMethod · 0.80
splitlistMethod · 0.80
update_idletasksMethod · 0.80
after_cancelMethod · 0.80
callMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected