docstr: Check highlighting of a given piece of code.
  
  This inserts just this code into the Text widget. It will then
  check that the resulting highlighting tag ranges exactly match
  those described in the given `tag_ranges` dict.
  
  Note that the irrelevant tags 'sel', 'TODO' and 'SYNC' are
  ignored.
docstr_tok: ["Check","highlighting","of","a","given","piece","of","code",".","This","inserts","just","this","code","into","the","Text","widget",".","It","will","then","check","that","the","resulting","highlighting","tag","ranges","exactly","match","those","described","in","the","given","`","tag_ranges","`","dict",".","Note","that","the","irrelevant","tags","'sel","'",",","'TODO","'","and","'SYNC","'","are","ignored","."]
code: def _assert_highlighting(self, source, tag_ranges):
      """Check highlighting of a given piece of code.
  
      This inserts just this code into the Text widget. It will then
      check that the resulting highlighting tag ranges exactly match
      those described in the given `tag_ranges` dict.
  
      Note that the irrelevant tags 'sel', 'TODO' and 'SYNC' are
      ignored.
      """
      text = self.text
  
      with mock.patch.object(colorizer.ColorDelegator, "notify_range"):
          text.delete("1.0", "end-1c")
          text.insert("insert", source)
          text.tag_add("TODO", "1.0", "end-1c")
          self.color.recolorize_main()
  
      # Make a dict with highlighting tag ranges in the Text widget.
      text_tag_ranges = {}
      for tag in set(text.tag_names()) - {"sel", "TODO", "SYNC"}:
          indexes = [rng.string for rng in text.tag_ranges(tag)]
          for index_pair in zip(indexes[::2], indexes[1::2]):
              text_tag_ranges.setdefault(tag, []).append(index_pair)
  
      self.assertEqual(text_tag_ranges, tag_ranges)
  
      with mock.patch.object(colorizer.ColorDelegator, "notify_range"):
          text.delete("1.0", "end-1c")
  
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 14 for calling the ColorDelegatorTest obj's underlying member method code with example usage: obj._assert_highlighting(source, tag_ranges) without return types