code: def test_find_good_parse_start(self):
      eq = self.assertEqual
      p = self.parser
      setcode = p.set_code
      start = p.find_good_parse_start
  
      def char_in_string_false(index):
          return False
  
      # First line starts with 'def' and ends with ':', then 0 is the pos.
      setcode("def spam():\n")
      eq(start(char_in_string_false), 0)
  
      # First line begins with a keyword in the list and ends
      # with an open brace, then 0 is the pos.  This is how
      # hyperparser calls this function as the newline is not added
      # in the editor, but rather on the call to setcode.
      setcode("class spam( " + " \n")
      eq(start(char_in_string_false), 0)
  
      # Split def across lines.
      setcode(
          '"""This is a module docstring"""\n'
          "class C:\n"
          "    def __init__(self, a,\n"
          "                 b=True):\n"
          "        pass\n"
      )
      pos0, pos = 33, 42  # Start of 'class...', '    def' lines.
  
      # Passing no value or non-callable should fail (issue 32989).
      with self.assertRaises(TypeError):
          start()
      with self.assertRaises(TypeError):
          start(False)
  
      # Make text look like a string.  This returns pos as the start
      # position, but it's set to None.
      self.assertIsNone(start(is_char_in_string=lambda index: True))
  
      # Make all text look like it's not in a string.  This means that it
      # found a good start position.
      eq(start(char_in_string_false), pos)
  
      # If the beginning of the def line is not in a string, then it
      # returns that as the index.
      eq(start(is_char_in_string=lambda index: index > pos), pos)
      # If the beginning of the def line is in a string, then it
      # looks for a previous index.
      eq(start(is_char_in_string=lambda index: index >= pos), pos0)
      # If everything before the 'def' is in a string, then returns None.
      # The non-continuation def line returns 44 (see below).
      eq(start(is_char_in_string=lambda index: index < pos), None)
  
      # Code without extra line break in def line - mostly returns the same
      # values.
      setcode(
          '"""This is a module docstring"""\n'
          "class C:\n"
          "    def __init__(self, a, b=True):\n"
          "        pass\n"
      )  # Does not affect class, def positions.
      eq(start(char_in_string_false), pos)
      eq(start(is_char_in_string=lambda index: index > pos), pos)
      eq(start(is_char_in_string=lambda index: index >= pos), pos0)
      # When the def line isn't split, this returns which doesn't match the
      # split line test.
      eq(start(is_char_in_string=lambda index: index < pos), pos)
  
imports: from idlelib import pyparse
  import unittest
  from collections import namedtuple
label_desc: Use image node_id 5 for calling the PyParseTest obj's underlying member method code with example usage: obj.test_find_good_parse_start() and returns: False