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

Method test_after_cancel

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

Source from the content-addressed store, hash-verified

217 self.assertEqual(count, 54)
218
219 def test_after_cancel(self):
220 root = self.root
221
222 def callback():
223 nonlocal count
224 count += 1
225
226 timer1 = root.after(5000, callback)
227 idle1 = root.after_idle(callback)
228
229 # No value for id raises a ValueError.
230 with self.assertRaises(ValueError):
231 root.after_cancel(None)
232
233 # Cancel timer event.
234 count = 0
235 (script, _) = root.tk.splitlist(root.tk.call('after', 'info', timer1))
236 root.tk.call(script)
237 self.assertEqual(count, 1)
238 root.after_cancel(timer1)
239 with self.assertRaises(tkinter.TclError):
240 root.tk.call(script)
241 self.assertEqual(count, 1)
242 with self.assertRaises(tkinter.TclError):
243 root.tk.call('after', 'info', timer1)
244
245 # Cancel same event - nothing happens.
246 root.after_cancel(timer1)
247
248 # Cancel idle event.
249 count = 0
250 (script, _) = root.tk.splitlist(root.tk.call('after', 'info', idle1))
251 root.tk.call(script)
252 self.assertEqual(count, 1)
253 root.after_cancel(idle1)
254 with self.assertRaises(tkinter.TclError):
255 root.tk.call(script)
256 self.assertEqual(count, 1)
257 with self.assertRaises(tkinter.TclError):
258 root.tk.call('after', 'info', idle1)
259
260 def test_after_info(self):
261 root = self.root

Callers

nothing calls this directly

Calls 7

afterMethod · 0.80
after_idleMethod · 0.80
after_cancelMethod · 0.80
splitlistMethod · 0.80
assertRaisesMethod · 0.45
callMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected