def html_tree_equal(received, expected):
 for attr in ('tag', 'attrib', 'text', 'tail'):
  if (getattr(received, attr) != getattr(expected, attr)):
   return False
 if (len(received) != len(expected)):
  return False
 if any(((not html_tree_equal(rec, exp)) for (rec, exp) in zip(received, expected))):
  return False
 return True

def html_tree_equal ( received , expected ) : for attr in ( 'tag' , 'attrib' , 'text' , 'tail' ) : if ( getattr ( received , attr ) != getattr ( expected , attr ) ) : return False if ( len ( received ) != len ( expected ) ) : return False if any ( ( ( not html_tree_equal ( rec , exp ) ) for ( rec , exp ) in zip ( received , expected ) ) ) : return False return True
returns whether two etree elements are the same .