<s> import formatter <EOL> import unittest <EOL> from test import test_support <EOL> htmllib = test_support . import_module ( '<STR_LIT>' , deprecated = True ) <EOL> class AnchorCollector ( htmllib . HTMLParser ) : <EOL> def __init__ ( self , * args , ** kw ) : <EOL> self . __anchors = [ ] <EOL> htmllib . HTMLParser . __init__ ( self , * args , ** kw ) <EOL> def get_anchor_info ( self ) : <EOL> return self . __anchors <EOL> def anchor_bgn ( self , * args ) : <EOL> self . __anchors . append ( args ) <EOL> class DeclCollector ( htmllib . HTMLParser ) : <EOL> def __init__ ( self , * args , ** kw ) : <EOL> self . __decls = [ ] <EOL> htmllib . HTMLParser . __init__ ( self , * args , ** kw ) <EOL> def get_decl_info ( self ) : <EOL> return self . __decls <EOL> def unknown_decl ( self , data ) : <EOL> self . __decls . append ( data ) <EOL> class HTMLParserTestCase ( unittest . TestCase ) : <EOL> def test_anchor_collection ( self ) : <EOL> parser = AnchorCollector ( formatter . NullFormatter ( ) , verbose = <NUM_LIT:1> ) <EOL> parser . feed ( <EOL> """<STR_LIT>""" ) <EOL> parser . close ( ) <EOL> self . assertEqual ( parser . get_anchor_info ( ) , <EOL> [ ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> def test_decl_collection ( self ) : <EOL> parser = DeclCollector ( formatter . NullFormatter ( ) , verbose = <NUM_LIT:1> ) <EOL> parser . feed ( <EOL> """<STR_LIT>""" ) <EOL> parser . close ( ) <EOL> self . assertEqual ( parser . get_decl_info ( ) , <EOL> [ "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( HTMLParserTestCase ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
