#NEWLINE# def test_special_attrs( self ) : #NEWLINE# #INDENT# def foo( x = 0 ) : #NEWLINE# #INDENT# 'TEST' #NEWLINE# return x #NEWLINE# #UNINDENT# with patch . object ( foo , '__defaults__' , ( 1 , ) ) : #NEWLINE# #INDENT# self . assertEqual ( foo ( ) , 1 ) #NEWLINE# #UNINDENT# self . assertEqual ( foo ( ) , 0 ) #NEWLINE# with patch . object ( foo , '__doc__' , 'FUN' ) : #NEWLINE# #INDENT# self . assertEqual ( foo . __doc__ , 'FUN' ) #NEWLINE# #UNINDENT# self . assertEqual ( foo . __doc__ , 'TEST' ) #NEWLINE# with patch . object ( foo , '__module__' , 'testpatch2' ) : #NEWLINE# #INDENT# self . assertEqual ( foo . __module__ , 'testpatch2' ) #NEWLINE# #UNINDENT# self . assertEqual ( foo . __module__ , __name__ ) #NEWLINE# if hasattr ( self . test_special_attrs , '__annotations__' ) : #NEWLINE# #INDENT# with patch . object ( foo , '__annotations__' , dict ( [ ( 's' , 1 ) ] ) ) : #NEWLINE# #INDENT# self . assertEqual ( foo . __annotations__ , dict ( [ ( 's' , 1 ) ] ) ) #NEWLINE# #UNINDENT# self . assertEqual ( foo . __annotations__ , dict ( ) ) #NEWLINE# #UNINDENT# if hasattr ( self . test_special_attrs , '__kwdefaults__' ) : #NEWLINE# #INDENT# foo = eval ( 'lambda *a, x=0: x' ) #NEWLINE# with patch . object ( foo , '__kwdefaults__' , dict ( [ ( 'x' , 1 ) ] ) ) : #NEWLINE# #INDENT# self . assertEqual ( foo ( ) , 1 ) #NEWLINE# #UNINDENT# self . assertEqual ( foo ( ) , 0 )