<s> from __future__ import print_function <EOL> import unittest <EOL> import wrapt <EOL> from compat import PY2 , PY3 , exec_ <EOL> @ wrapt . decorator <EOL> def passthru_decorator ( wrapped , instance , args , kwargs ) : <EOL> return wrapped ( * args , ** kwargs ) <EOL> class TestUpdateAttributes ( unittest . TestCase ) : <EOL> def test_update_name ( self ) : <EOL> @ passthru_decorator <EOL> def function ( ) : <EOL> pass <EOL> self . assertEqual ( function . __name__ , '<STR_LIT>' ) <EOL> function . __name__ = '<STR_LIT>' <EOL> self . assertEqual ( function . __name__ , '<STR_LIT>' ) <EOL> def test_update_name_modified_on_original ( self ) : <EOL> def function ( ) : <EOL> pass <EOL> def wrapper ( wrapped , instance , args , kwargs ) : <EOL> return wrapped ( * args , ** kwargs ) <EOL> instance = wrapt . FunctionWrapper ( function , wrapper ) <EOL> self . assertEqual ( instance . __name__ , '<STR_LIT>' ) <EOL> instance . __name__ = '<STR_LIT>' <EOL> self . assertEqual ( function . __name__ , '<STR_LIT>' ) <EOL> self . assertEqual ( instance . __name__ , '<STR_LIT>' ) <EOL> def test_update_qualname ( self ) : <EOL> @ passthru_decorator <EOL> def function ( ) : <EOL> pass <EOL> if PY3 : <EOL> method = self . test_update_qualname <EOL> self . assertEqual ( function . __qualname__ , <EOL> ( method . __qualname__ + '<STR_LIT>' ) ) <EOL> function . __qualname__ = '<STR_LIT>' <EOL> self . assertEqual ( function . __qualname__ , '<STR_LIT>' ) <EOL> def test_update_qualname_modified_on_original ( self ) : <EOL> def function ( ) : <EOL> pass <EOL> def wrapper ( wrapped , instance , args , kwargs ) : <EOL> return wrapped ( * args , ** kwargs ) <EOL> instance = wrapt . FunctionWrapper ( function , wrapper ) <EOL> if PY3 : <EOL> method = self . test_update_qualname_modified_on_original <EOL> self . assertEqual ( instance . __qualname__ , <EOL> ( method . __qualname__ + '<STR_LIT>' ) ) <EOL> instance . __qualname__ = '<STR_LIT>' <EOL> self . assertEqual ( function . __qualname__ , '<STR_LIT>' ) <EOL> self . assertEqual ( instance . __qualname__ , '<STR_LIT>' ) <EOL> def test_update_module ( self ) : <EOL> @ passthru_decorator <EOL> def function ( ) : <EOL> pass <EOL> self . assertEqual ( function . __module__ , __name__ ) <EOL> function . __module__ = '<STR_LIT>' <EOL> self . assertEqual ( function . __module__ , '<STR_LIT>' ) <EOL> def test_update_module_modified_on_original ( self ) : <EOL> def function ( ) : <EOL> pass <EOL> def wrapper ( wrapped , instance , args , kwargs ) : <EOL> return wrapped ( * args , ** kwargs ) <EOL> instance = wrapt . FunctionWrapper ( function , wrapper ) <EOL> self . assertEqual ( instance . __module__ , __name__ ) <EOL> instance . __module__ = '<STR_LIT>' <EOL> self . assertEqual ( function . __module__ , '<STR_LIT>' ) <EOL> self . assertEqual ( instance . __module__ , '<STR_LIT>' ) <EOL> def test_update_doc ( self ) : <EOL> @ passthru_decorator <EOL> def function ( ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> self . assertEqual ( function . __doc__ , "<STR_LIT>" ) <EOL> function . __doc__ = '<STR_LIT>' <EOL> self . assertEqual ( function . __doc__ , '<STR_LIT>' ) <EOL> def test_update_doc_modified_on_original ( self ) : <EOL> def function ( ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def wrapper ( wrapped , instance , args , kwargs ) : <EOL> return wrapped ( * args , ** kwargs ) <EOL> instance = wrapt . FunctionWrapper ( function , wrapper ) <EOL> self . assertEqual ( instance . __doc__ , "<STR_LIT>" ) <EOL> instance . __doc__ = '<STR_LIT>' <EOL> self . assertEqual ( function . __doc__ , '<STR_LIT>' ) <EOL> self . assertEqual ( instance . __doc__ , '<STR_LIT>' ) <EOL> def test_update_annotations ( self ) : <EOL> @ passthru_decorator <EOL> def function ( ) : <EOL> pass <EOL> if PY3 : <EOL> self . assertEqual ( function . __annotations__ , { } ) <EOL> else : <EOL> def run ( * args ) : <EOL> function . __annotations__ <EOL> self . assertRaises ( AttributeError , run , ( ) ) <EOL> override_annotations = { '<STR_LIT>' : '<STR_LIT>' } <EOL> function . __annotations__ = override_annotations <EOL> self . assertEqual ( function . __annotations__ , override_annotations ) <EOL> def test_update_annotations_modified_on_original ( self ) : <EOL> def function ( ) : <EOL> pass <EOL> def wrapper ( wrapped , instance , args , kwargs ) : <EOL> return wrapped ( * args , ** kwargs ) <EOL> instance = wrapt . FunctionWrapper ( function , wrapper ) <EOL> if PY3 : <EOL> self . assertEqual ( instance . __annotations__ , { } ) <EOL> else : <EOL> def run ( * args ) : <EOL> instance . __annotations__ <EOL> self . assertRaises ( AttributeError , run , ( ) ) <EOL> override_annotations = { '<STR_LIT>' : '<STR_LIT>' } <EOL> instance . __annotations__ = override_annotations <EOL> self . assertEqual ( function . __annotations__ , override_annotations ) <EOL> self . assertEqual ( instance . __annotations__ , override_annotations ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
