#NEWLINE# def test_make_parser( ) : #NEWLINE# #INDENT# class MyParser ( object ) : #NEWLINE# #INDENT# def __init__( self , some_config ) : #NEWLINE# #INDENT# self . some_config = some_config #NEWLINE# #UNINDENT# #UNINDENT# parsers = [ make_parser ( ) , make_parser ( 'page3' ) , make_parser ( CSSPage3Parser ) , make_parser ( MyParser , some_config = 42 ) , make_parser ( CSSPage3Parser , MyParser , some_config = 42 ) , make_parser ( MyParser , 'page3' , some_config = 42 ) ] #NEWLINE# for ( parser , exp ) in zip ( parsers , [ False , True , True , False , True , True ] ) : #NEWLINE# #INDENT# assert ( isinstance ( parser , CSSPage3Parser ) == exp ) #NEWLINE# #UNINDENT# for ( parser , exp ) in zip ( parsers , [ False , False , False , True , True , True ] ) : #NEWLINE# #INDENT# assert ( isinstance ( parser , MyParser ) == exp ) #NEWLINE# #UNINDENT# for parser in parsers [ 3 : ] : #NEWLINE# #INDENT# assert ( parser . some_config == 42 ) #NEWLINE# #UNINDENT# raises ( TypeError , make_parser , some_config = 4 ) #NEWLINE# raises ( TypeError , make_parser , 'page3' , some_config = 4 ) #NEWLINE# raises ( TypeError , make_parser , MyParser ) #NEWLINE# raises ( TypeError , make_parser , MyParser , some_config = 4 , other_config = 7 )