code: def test_recolorize(self, mock_recmain):
      text = self.text
      color = self.color
      eq = self.assertEqual
      # Call recolorize manually and not scheduled.
      text.after_cancel(color.after_id)
  
      # No delegate.
      save_delegate = color.delegate
      color.delegate = None
      color.recolorize()
      mock_recmain.assert_not_called()
      color.delegate = save_delegate
  
      # Toggle off colorizing.
      color.allow_colorizing = False
      color.recolorize()
      mock_recmain.assert_not_called()
      color.allow_colorizing = True
  
      # Colorizing in progress.
      color.colorizing = True
      color.recolorize()
      mock_recmain.assert_not_called()
      color.colorizing = False
  
      # Colorizing is done, but not completed, so rescheduled.
      color.recolorize()
      self.assertFalse(color.stop_colorizing)
      self.assertFalse(color.colorizing)
      mock_recmain.assert_called()
      eq(mock_recmain.call_count, 1)
      # Rescheduled when TODO tag still exists.
      eq(self.root.tk.call("after", "info", color.after_id)[1], "timer")
  
      # No changes to text, so no scheduling added.
      text.tag_remove("TODO", "1.0", "end")
      color.recolorize()
      self.assertFalse(color.stop_colorizing)
      self.assertFalse(color.colorizing)
      mock_recmain.assert_called()
      eq(mock_recmain.call_count, 2)
      self.assertIsNone(color.after_id)
  
imports: from idlelib import colorizer
  from test.support import requires
  import unittest
  from unittest import mock
  from idlelib.idle_test.tkinter_testing_utils import run_in_tk_mainloop
  from functools import partial
  import textwrap
  from tkinter import Tk, Text
  from idlelib import config
  from idlelib.percolator import Percolator
label_desc: Use image node_id 12 for calling the ColorDelegatorTest obj's underlying member method code with example usage: obj.test_recolorize(mock_recmain) without return types