parameters: (output1, output2, allowed, ignore1, ignore2)
return_statement: return None, source
docstring: Returns a tuple (difference, source).
  
    The difference is None if there's no difference, otherwise a string
    with a readable diff.
  
    The source is the last source output within the test case, or None if no
    such output existed.
docstring_summary: Returns a tuple (difference, source).
docstring_tokens: Returns a tuple ( difference source ) .
function: def diff_output(output1, output2, allowed, ignore1, ignore2):
    """Returns a tuple (difference, source).
  
    The difference is None if there's no difference, otherwise a string
    with a readable diff.
  
    The source is the last source output within the test case, or None if no
    such output existed.
    """
    def useful_line(ignore):
      def fun(line):
        return all(not e.match(line) for e in ignore)
      return fun
  
    lines1 = list(filter(useful_line(ignore1), output1))
    lines2 = list(filter(useful_line(ignore2), output2))
  
    # This keeps track where we are in the original source file of the fuzz
    # test case.
    source = None
  
    for ((line1, lookahead1), (line2, lookahead2)) in zip_longest(
        line_pairs(lines1), line_pairs(lines2), fillvalue=(None, None)):
  
      # Only one of the two iterators should run out.
      assert not (line1 is None and line2 is None)
  
      # One iterator ends earlier.
      if line1 is None:
        return '+ %s' % short_line_output(line2), source
      if line2 is None:
        return '- %s' % short_line_output(line1), source
  
      # If lines are equal, no further checks are necessary.
      if line1 == line2:
        # Instrumented original-source-file output must be equal in both
        # versions. It only makes sense to update it here when both lines
        # are equal.
        if line1.startswith(ORIGINAL_SOURCE_PREFIX):
          source = line1[len(ORIGINAL_SOURCE_PREFIX):]
        continue
  
      # Look ahead. If next line is a caret, ignore this line.
      if caret_match(lookahead1, lookahead2):
        continue
  
      # Check if a regexp allows these lines to be different.
      if ignore_by_regexp(line1, line2, allowed):
        continue
  
      # Lines are different.
      return (
          '- %s\n+ %s' % (short_line_output(line1), short_line_output(line2)),
          source,
      )
  
    # No difference found.
    return None, source
function_tokens: def diff_output ( output1 , output2 , allowed , ignore1 , ignore2 ) : def useful_line ( ignore ) : def fun ( line ) : return all ( not e . match ( line ) for e in ignore ) return fun lines1 = list ( filter ( useful_line ( ignore1 ) , output1 ) ) lines2 = list ( filter ( useful_line ( ignore2 ) , output2 ) ) # This keeps track where we are in the original source file of the fuzz # test case. source = None for ( ( line1 , lookahead1 ) , ( line2 , lookahead2 ) ) in zip_longest ( line_pairs ( lines1 ) , line_pairs ( lines2 ) , fillvalue = ( None , None ) ) : # Only one of the two iterators should run out. assert not ( line1 is None and line2 is None ) # One iterator ends earlier. if line1 is None : return '+ %s' % short_line_output ( line2 ) , source if line2 is None : return '- %s' % short_line_output ( line1 ) , source # If lines are equal, no further checks are necessary. if line1 == line2 : # Instrumented original-source-file output must be equal in both # versions. It only makes sense to update it here when both lines # are equal. if line1 . startswith ( ORIGINAL_SOURCE_PREFIX ) : source = line1 [ len ( ORIGINAL_SOURCE_PREFIX ) : ] continue # Look ahead. If next line is a caret, ignore this line. if caret_match ( lookahead1 , lookahead2 ) : continue # Check if a regexp allows these lines to be different. if ignore_by_regexp ( line1 , line2 , allowed ) : continue # Lines are different. return ( '- %s\n+ %s' % ( short_line_output ( line1 ) , short_line_output ( line2 ) ) , source , ) # No difference found. return None , source