#NEWLINE# def test_with_opt( self ) : #NEWLINE# #INDENT# T = optional_return_type ( [ 'a' , 'b' ] , [ 'c' ] ) #NEWLINE# for o in [ T ( 1 , 2 , 3 ) , T ( 1 , b = 2 , c = 3 ) , T ( a = 1 , b = 2 , c = 3 ) ] : #NEWLINE# #INDENT# self . assertEqual ( o , ( 1 , 2 ) ) #NEWLINE# self . assertEqual ( o [ 0 ] , 1 ) #NEWLINE# self . assertEqual ( o [ 1 ] , 2 ) #NEWLINE# self . assertRaises ( IndexError , ( lambda : o [ 2 ] ) ) #NEWLINE# self . assertEqual ( o . a , 1 ) #NEWLINE# self . assertEqual ( o . b , 2 ) #NEWLINE# self . assertEqual ( o . c , 3 ) #NEWLINE# #UNINDENT# for o in [ T ( 1 , 2 ) , T ( 1 , b = 2 ) , T ( a = 1 , b = 2 ) ] : #NEWLINE# #INDENT# self . assertEqual ( o , ( 1 , 2 ) ) #NEWLINE# self . assertEqual ( o [ 0 ] , 1 ) #NEWLINE# self . assertEqual ( o [ 1 ] , 2 ) #NEWLINE# self . assertRaises ( IndexError , ( lambda : o [ 2 ] ) ) #NEWLINE# self . assertEqual ( o . a , 1 ) #NEWLINE# self . assertEqual ( o . b , 2 ) #NEWLINE# self . assertRaises ( AttributeError , ( lambda : o . c ) ) #NEWLINE# #UNINDENT# self . assertRaises ( TypeError , ( lambda : T ( 1 ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : T ( b = 1 , c = 2 ) ) ) #NEWLINE# self . assertRaises ( TypeError , ( lambda : T ( c = 1 ) ) )