(self)
| 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 |
nothing calls this directly
no test coverage detected