code: def format_output_compare(self, key, left, right):
          
          if isinstance(left, six.string_types):
              left = _trim_base64(left)
          if isinstance(right, six.string_types):
              right = _trim_base64(right)
  
          cc = self.colors
  
          self.comparison_traceback.append(
              cc.OKBLUE
              + " mismatch '%s'" % key
              + cc.FAIL)
  
          # Use comparison repr from pytest:
          hook_result = self.ihook.pytest_assertrepr_compare(
              config=self.config, op='==', left=left, right=right)
          for new_expl in hook_result:
              if new_expl:
                  new_expl = ['  %s' % line.replace("\n", "\\n") for line in new_expl]
                  self.comparison_traceback.append("\n assert reference_output == test_output failed:\n")
                  self.comparison_traceback.extend(new_expl)
                  break
          else:
              # Fallback repr:
              self.comparison_traceback.append(
                  "  <<<<<<<<<<<< Reference output from ipynb file:"
                  + cc.ENDC)
              self.comparison_traceback.append(_indent(left))
              self.comparison_traceback.append(
                  cc.FAIL
                  + '  ============ disagrees with newly computed (test) output:'
                  + cc.ENDC)
              self.comparison_traceback.append(_indent(right))
              self.comparison_traceback.append(
                  cc.FAIL
                  + '  >>>>>>>>>>>>')
          self.comparison_traceback.append(cc.ENDC)
docs: Format an output for printing