code: def format_(blocks):
      
  
      tests = list()
      function_count = 0  # For each test to have a unique name
  
      for block in blocks:
  
          # Validate docstring format of body
          if not any(line[:3] == ">>>" for line in block["body"]):
              # A doctest requires at least one `>>>` directive.
              block["body"].insert(0, ">>> assert False, "
                                   "'Body must be in docstring format'\n")
  
          # Validate binding on first line
          if not block["binding"] in ("PySide", "PySide2", "PyQt5", "PyQt4"):
              block["body"].insert(0, ">>> assert False, "
                                   "'Invalid binding'\n")
  
          if sys.version_info > (3, 4) and block["binding"] in ("PySide"):
              # Skip caveat test if it requires PySide on Python > 3.4
              continue
          else:
              function_count += 1
              block["header"] = block["header"]
              block["count"] = str(function_count)
              block["body"] = "    ".join(block["body"])
              tests.append("""\
  
  def test_{count}_{header}():
      '''Test {header}
  
      >>> import os, sys
      >>> PYTHON = sys.version_info[0]
      >>> long = int if PYTHON == 3 else long
      >>> _ = os.environ.pop("QT_VERBOSE", None)  # Disable debug output
      >>> os.environ["QT_PREFERRED_BINDING"] = "{binding}"
      {body}
      '''
  
      """.format(**block))
  
      return tests
docs: Produce Python module from blocks of tests
  
      Arguments:
          blocks (list): Blocks of tests from func:`parse()`