code: def test_after_cancel(self):
      root = self.root
  
      def callback():
          nonlocal count
          count += 1
  
      timer1 = root.after(5000, callback)
      idle1 = root.after_idle(callback)
  
      # No value for id raises a ValueError.
      with self.assertRaises(ValueError):
          root.after_cancel(None)
  
      # Cancel timer event.
      count = 0
      (script, _) = root.tk.splitlist(
          root.tk.call("after", "info", timer1)
      )
      root.tk.call(script)
      self.assertEqual(count, 1)
      root.after_cancel(timer1)
      with self.assertRaises(tkinter.TclError):
          root.tk.call(script)
      self.assertEqual(count, 1)
      with self.assertRaises(tkinter.TclError):
          root.tk.call("after", "info", timer1)
  
      # Cancel same event - nothing happens.
      root.after_cancel(timer1)
  
      # Cancel idle event.
      count = 0
      (script, _) = root.tk.splitlist(
          root.tk.call("after", "info", idle1)
      )
      root.tk.call(script)
      self.assertEqual(count, 1)
      root.after_cancel(idle1)
      with self.assertRaises(tkinter.TclError):
          root.tk.call(script)
      self.assertEqual(count, 1)
      with self.assertRaises(tkinter.TclError):
          root.tk.call("after", "info", idle1)
  
imports: import functools
  import unittest
  import tkinter
  from tkinter import TclError
  import enum
  from test import support
  from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tk
label_desc: Use image node_id 9 for calling the MiscTest obj's underlying member method code with example usage: obj.test_after_cancel() without return types