def tokensMatch(expectedTokens, receivedTokens, ignoreErrorOrder, ignoreErrors=False):
 checkSelfClosing = False
 for token in expectedTokens:
  if (((token[0] == 'StartTag') and (len(token) == 4)) or ((token[0] == 'EndTag') and (len(token) == 3))):
   checkSelfClosing = True
   break
 if (not checkSelfClosing):
  for token in receivedTokens:
   if ((token[0] == 'StartTag') or (token[0] == 'EndTag')):
    token.pop()
 if ((not ignoreErrorOrder) and (not ignoreErrors)):
  return (expectedTokens == receivedTokens)
 else:
  tokens = {'expected': [[], []], 'received': [[], []]}
  for (tokenType, tokenList) in zip(tokens.keys(), (expectedTokens, receivedTokens)):
   for token in tokenList:
    if (token != 'ParseError'):
     tokens[tokenType][0].append(token)
    elif (not ignoreErrors):
     tokens[tokenType][1].append(token)
  return (tokens['expected'] == tokens['received'])

def tokensMatch ( expectedTokens , receivedTokens , ignoreErrorOrder , ignoreErrors = False ) : checkSelfClosing = False for token in expectedTokens : if ( ( ( token [ 0 ] == 'StartTag' ) and ( len ( token ) == 4 ) ) or ( ( token [ 0 ] == 'EndTag' ) and ( len ( token ) == 3 ) ) ) : checkSelfClosing = True break if ( not checkSelfClosing ) : for token in receivedTokens : if ( ( token [ 0 ] == 'StartTag' ) or ( token [ 0 ] == 'EndTag' ) ) : token . pop ( ) if ( ( not ignoreErrorOrder ) and ( not ignoreErrors ) ) : return ( expectedTokens == receivedTokens ) else : tokens = { 'expected' : [ [ ] , [ ] ] , 'received' : [ [ ] , [ ] ] } for ( tokenType , tokenList ) in zip ( tokens . keys ( ) , ( expectedTokens , receivedTokens ) ) : for token in tokenList : if ( token != 'ParseError' ) : tokens [ tokenType ] [ 0 ] . append ( token ) elif ( not ignoreErrors ) : tokens [ tokenType ] [ 1 ] . append ( token ) return ( tokens [ 'expected' ] == tokens [ 'received' ] )
test whether the test has passed or failed if the ignoreerrororder flag is set to true we dont test the relative positions of parse errors and non parse errors .