<s> '''<STR_LIT>''' <EOL> import nose <EOL> from python_toolbox import import_tools <EOL> from python_toolbox . temp_value_setting import TempValueSetter <EOL> import python_toolbox <EOL> from python_toolbox . address_tools import describe , resolve <EOL> prefix = __name__ + '<STR_LIT:.>' <EOL> def test_on_locally_defined_class ( ) : <EOL> raise nose . SkipTest ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> result = describe ( A . B ) <EOL> assert result == prefix + '<STR_LIT>' <EOL> assert resolve ( result ) is A . B <EOL> result = describe ( A . C . D . deeper_method ) <EOL> assert result == prefix + '<STR_LIT>' <EOL> assert resolve ( result ) == A . C . D . deeper_method <EOL> result = describe ( A . C . D . deeper_method , root = A . C ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , root = A . C ) == A . C . D . deeper_method <EOL> result = describe ( A . C . D . deeper_method , root = '<STR_LIT>' ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , root = '<STR_LIT>' ) == A . C . D . deeper_method <EOL> def test_on_stdlib ( ) : <EOL> '''<STR_LIT>''' <EOL> import email . encoders <EOL> result = describe ( email . encoders ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result ) is email . encoders <EOL> result = describe ( email . encoders , root = email . encoders ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , root = email . encoders ) is email . encoders <EOL> result = describe ( email . encoders , namespace = email ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , namespace = email ) is email . encoders <EOL> result = describe ( email . encoders , root = email . encoders , namespace = email ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , root = email . encoders , namespace = email ) is email . encoders <EOL> def test_on_python_toolbox ( ) : <EOL> '''<STR_LIT>''' <EOL> import python_toolbox . caching <EOL> result = describe ( python_toolbox . caching . cached_property . CachedProperty ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result ) is python_toolbox . caching . cached_property . CachedProperty <EOL> result = describe ( python_toolbox . caching . cached_property . CachedProperty , <EOL> shorten = True ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result ) is python_toolbox . caching . cached_property . CachedProperty <EOL> import python_toolbox . nifty_collections <EOL> result = describe ( python_toolbox . nifty_collections . weak_key_default_dict . <EOL> WeakKeyDefaultDict , <EOL> shorten = True , <EOL> root = python_toolbox . nifty_collections . <EOL> weak_key_default_dict ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( <EOL> result , <EOL> root = python_toolbox . nifty_collections . weak_key_default_dict <EOL> ) is python_toolbox . nifty_collections . WeakKeyDefaultDict <EOL> result = describe ( python_toolbox . caching . cached_property . CachedProperty , <EOL> shorten = True , <EOL> namespace = python_toolbox ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , namespace = python_toolbox ) is python_toolbox . caching . CachedProperty <EOL> result = describe ( python_toolbox . caching . CachedProperty , shorten = True , <EOL> namespace = python_toolbox . __dict__ ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , namespace = python_toolbox . __dict__ ) is python_toolbox . caching . CachedProperty <EOL> result = describe ( python_toolbox . caching . CachedProperty , shorten = True , <EOL> namespace = '<STR_LIT>' ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , namespace = '<STR_LIT>' ) is python_toolbox . caching . CachedProperty <EOL> result = describe ( python_toolbox . caching . CachedProperty , shorten = True , <EOL> namespace = '<STR_LIT>' ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , namespace = '<STR_LIT>' ) is python_toolbox . caching . CachedProperty <EOL> result = describe ( python_toolbox . caching . cached_property . CachedProperty , <EOL> root = python_toolbox ) <EOL> assert result == '<STR_LIT>' <EOL> assert resolve ( result , root = python_toolbox ) is python_toolbox . caching . cached_property . CachedProperty <EOL> def test_on_local_modules ( ) : <EOL> '''<STR_LIT>''' <EOL> import python_toolbox <EOL> from . sample_module_tree import w <EOL> z = resolve ( '<STR_LIT>' , root = w ) <EOL> result = describe ( z , root = w ) <EOL> assert result == '<STR_LIT>' <EOL> result = describe ( z , shorten = True , root = w ) <EOL> assert result == '<STR_LIT>' <EOL> result = describe ( z , shorten = True , root = w ) <EOL> assert result == '<STR_LIT>' <EOL> result = describe ( z , shorten = True , root = w , namespace = '<STR_LIT:email>' ) <EOL> assert result == '<STR_LIT>' <EOL> result = describe ( z , shorten = True , root = python_toolbox , namespace = w ) <EOL> assert result == '<STR_LIT>' <EOL> result = describe ( z , shorten = True , root = w . x ) <EOL> assert result == '<STR_LIT>' <EOL> def test_on_ignore_confusing_namespace ( ) : <EOL> '''<STR_LIT>''' <EOL> import email . encoders <EOL> import marshal <EOL> result = describe ( <EOL> email , <EOL> shorten = True , <EOL> namespace = { '<STR_LIT:e>' : email } <EOL> ) <EOL> assert result == '<STR_LIT:email>' <EOL> result = describe ( <EOL> email . encoders , <EOL> namespace = { '<STR_LIT:e>' : email , '<STR_LIT:email>' : email } <EOL> ) <EOL> assert result == '<STR_LIT>' <EOL> result = describe ( <EOL> email . encoders , <EOL> root = marshal , <EOL> namespace = { '<STR_LIT:e>' : email , '<STR_LIT:email>' : email } <EOL> ) <EOL> assert result == '<STR_LIT>' <EOL> def test_address_in_expression ( ) : <EOL> '''<STR_LIT>''' <EOL> import email . encoders <EOL> import marshal <EOL> assert describe ( [ object , email . encoders , marshal ] ) == '<STR_LIT>' <EOL> assert describe ( [ email . encoders , <NUM_LIT:7> , ( <NUM_LIT:1> , <NUM_LIT:3> ) , marshal ] ) == '<STR_LIT>' <EOL> def test_multiprocessing_lock ( ) : <EOL> '''<STR_LIT>''' <EOL> import multiprocessing <EOL> lock = multiprocessing . Lock ( ) <EOL> describe ( lock ) <EOL> def test_bad_module_name ( ) : <EOL> '''<STR_LIT>''' <EOL> import email <EOL> non_sensical_module_name = '<STR_LIT>' <EOL> my_locals = locals ( ) . copy ( ) <EOL> my_locals [ '<STR_LIT>' ] = non_sensical_module_name <EOL> exec '<STR_LIT>' in my_locals <EOL> exec ( '<STR_LIT>' <EOL> '<STR_LIT>' ) in my_locals <EOL> f , A = my_locals [ '<STR_LIT:f>' ] , my_locals [ '<STR_LIT:A>' ] <EOL> assert describe ( f ) == '<STR_LIT:.>' . join ( ( non_sensical_module_name , '<STR_LIT:f>' ) ) <EOL> assert describe ( f , shorten = True , root = email , namespace = { } ) == '<STR_LIT:.>' . join ( ( non_sensical_module_name , '<STR_LIT:f>' ) ) <EOL> assert describe ( A ) == '<STR_LIT:.>' . join ( ( non_sensical_module_name , '<STR_LIT:A>' ) ) <EOL> assert describe ( A , shorten = True , root = email , namespace = { } ) == '<STR_LIT:.>' . join ( ( non_sensical_module_name , '<STR_LIT:A>' ) ) <EOL> assert describe ( A . m ) == '<STR_LIT:.>' . join ( ( non_sensical_module_name , '<STR_LIT>' ) ) <EOL> assert describe ( A . m , shorten = True , root = email , namespace = { } ) == '<STR_LIT:.>' . join ( ( non_sensical_module_name , '<STR_LIT>' ) ) <EOL> def test_function_in_something ( ) : <EOL> '''<STR_LIT>''' <EOL> raise nose . SkipTest ( "<STR_LIT>" ) <EOL> assert describe ( { <NUM_LIT:1> : sum } ) == '<STR_LIT>' <EOL> assert describe ( ( sum , sum , list , chr ) ) == '<STR_LIT>' <EOL> def test_function_in_main ( ) : <EOL> '''<STR_LIT>''' <EOL> with TempValueSetter ( ( globals ( ) , '<STR_LIT>' ) , '<STR_LIT:__main__>' ) : <EOL> def f ( x ) : <EOL> pass <EOL> assert f . __module__ == '<STR_LIT:__main__>' <EOL> assert f . __module__ == '<STR_LIT:__main__>' <EOL> import __main__ <EOL> __main__ . f = f <EOL> del __main__ <EOL> assert describe ( f ) == '<STR_LIT>' <EOL> assert resolve ( describe ( f ) ) is f </s>
