• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python address_tools.describe函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中python_toolbox.address_tools.describe函数的典型用法代码示例。如果您正苦于以下问题:Python describe函数的具体用法?Python describe怎么用?Python describe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了describe函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_function_in_something

def test_function_in_something():
    '''Test `describe` doesn't fail when describing `{1: sum}`.'''
    if python_toolbox.__version_info__ <= (0, 6, 11, 'release'):
        raise nose.SkipTest("This test doesn't pass in `python_toolbox`"
                            "version 0.6.11 and below.")
    assert describe({1: sum}) == '{1: sum}'
    assert describe((sum, sum, list, chr)) == '(sum, sum, list, chr)'
开发者ID:rfdiazpr,项目名称:python_toolbox,代码行数:7,代码来源:test_describe.py


示例2: test_on_locally_defined_class

def test_on_locally_defined_class():
    
    ###########################################################################
    # Testing for locally defined class:
    
    
    if python_toolbox.__version_info__ <= (0, 6, 11, 'release'):
        raise nose.SkipTest("This test doesn't pass in `python_toolbox` "
                            "version 0.6.11 and below, because `describe` :"
                            "doesn't support nested classes yet.")
    
    result = describe(A.B)
    assert result == prefix + 'A.B'
    assert resolve(result) is A.B
    
    result = describe(A.C.D.deeper_method)
    assert result == prefix + 'A.C.D.deeper_method'
    assert resolve(result) == A.C.D.deeper_method
    
    result = describe(A.C.D.deeper_method, root=A.C)
    assert result == 'C.D.deeper_method'
    assert resolve(result, root=A.C) == A.C.D.deeper_method
    
    result = describe(A.C.D.deeper_method, root='A.C.D')
    assert result == 'D.deeper_method'
    assert resolve(result, root='A.C.D') == A.C.D.deeper_method
开发者ID:rfdiazpr,项目名称:python_toolbox,代码行数:26,代码来源:test_describe.py


示例3: test_multiprocessing_lock

def test_multiprocessing_lock():
    '''Test `describe` works for `multiprocessing.Lock()`.'''
    if not import_tools.exists('multiprocessing'):
        raise nose.SkipTest('`multiprocessing` not installed')
    import multiprocessing
    lock = multiprocessing.Lock()
    describe(lock)
开发者ID:rfdiazpr,项目名称:python_toolbox,代码行数:7,代码来源:test_describe.py


示例4: test_address_in_expression

def test_address_in_expression():
    '''Test `describe` works for an address inside an expression.'''
    
    import email.encoders
    import marshal
    
    assert describe([object, email.encoders, marshal]) == \
           '[object, email.encoders, marshal]'
    
    assert describe([email.encoders, 7, (1, 3), marshal]) == \
           '[email.encoders, 7, (1, 3), marshal]'
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:11,代码来源:test_describe.py


示例5: test_on_python_toolbox

def test_on_python_toolbox():
    '''Test `describe` for various `python_toolbox` modules.'''
    
    import python_toolbox.caching
    result = describe(python_toolbox.caching.cached_property.CachedProperty)
    assert result == 'python_toolbox.caching.cached_property.CachedProperty'
    assert resolve(result) is \
                          python_toolbox.caching.cached_property.CachedProperty
    
    result = describe(python_toolbox.caching.cached_property.CachedProperty,
                      shorten=True)
    assert result == 'python_toolbox.caching.CachedProperty'
    assert resolve(result) is \
                          python_toolbox.caching.cached_property.CachedProperty
    
    import python_toolbox.nifty_collections
    result = describe(python_toolbox.nifty_collections.weak_key_default_dict.
                                                            WeakKeyDefaultDict,
                      shorten=True,
                      root=python_toolbox.nifty_collections.
                                                         weak_key_default_dict)
    assert result == 'weak_key_default_dict.WeakKeyDefaultDict'
    assert resolve(
        result,
        root=python_toolbox.nifty_collections.weak_key_default_dict
        ) is python_toolbox.nifty_collections.WeakKeyDefaultDict
    
    result = describe(python_toolbox.caching.cached_property.CachedProperty,
                      shorten=True,
                      namespace=python_toolbox)
    assert result == 'caching.CachedProperty'
    assert resolve(result, namespace=python_toolbox) is \
                                          python_toolbox.caching.CachedProperty
    
    result = describe(python_toolbox.caching.CachedProperty, shorten=True,
                      namespace=python_toolbox.__dict__)
    assert result == 'caching.CachedProperty'
    assert resolve(result, namespace=python_toolbox.__dict__) is \
           python_toolbox.caching.CachedProperty
    
    result = describe(python_toolbox.caching.CachedProperty, shorten=True,
                      namespace='python_toolbox')
    assert result == 'caching.CachedProperty'
    assert resolve(result, namespace='python_toolbox') is \
                                          python_toolbox.caching.CachedProperty
    
    result = describe(python_toolbox.caching.CachedProperty, shorten=True,
                      namespace='python_toolbox.__dict__')
    assert result == 'caching.CachedProperty'
    assert resolve(result, namespace='python_toolbox.__dict__') is \
           python_toolbox.caching.CachedProperty
    
    result = describe(python_toolbox.caching.cached_property.CachedProperty,
                      root=python_toolbox)
    assert result == 'python_toolbox.caching.cached_property.CachedProperty'
    assert resolve(result, root=python_toolbox) is \
                          python_toolbox.caching.cached_property.CachedProperty
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:57,代码来源:test_describe.py


示例6: test_on_stdlib

def test_on_stdlib():
    '''Test `describe` for various stdlib modules.'''
    
    import email.encoders
    result = describe(email.encoders)
    assert result == 'email.encoders'
    assert resolve(result) is email.encoders
    
    result = describe(email.encoders, root=email.encoders)
    assert result == 'encoders'
    assert resolve(result, root=email.encoders) is email.encoders
    
    result = describe(email.encoders, namespace=email)
    assert result == 'encoders'
    assert resolve(result, namespace=email) is email.encoders
    
    result = describe(email.encoders, root=email.encoders, namespace=email)
    assert result == 'encoders'
    assert resolve(result, root=email.encoders, namespace=email) is \
           email.encoders
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:20,代码来源:test_describe.py


示例7: test_on_local_modules

def test_on_local_modules():
    '''Test `describe` on local, relatively-imported modules.'''
    import python_toolbox
    
    from .sample_module_tree import w
    
    z = resolve('w.x.y.z', root=w)

    result = describe(z, root=w)
    assert result == 'w.x.y.z'
    
    result = describe(z, shorten=True, root=w)
    assert result == 'w.y.z'
    
    result = describe(z, shorten=True, root=w)
    assert result == 'w.y.z'
    
    result = describe(z, shorten=True, root=w, namespace='email')
    assert result == 'w.y.z'
    
    result = describe(z, shorten=True, root=python_toolbox, namespace=w)
    assert result == 'y.z'
    
    result = describe(z, shorten=True, root=w.x)
    assert result == 'x.y.z'
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:25,代码来源:test_describe.py


示例8: __repr__

 def __repr__(self):
     '''
     Get a string representation of the emitter.
     
     Example output:        
     <python_toolbox.emitting.emitter.Emitter 'tree_modified' at
     0x1c013d0>
     '''
     return '<%s %sat %s>' % (
         address_tools.describe(type(self), shorten=True),
         ''.join(("'", self.name, "' ")) if self.name else '',
         hex(id(self))
     )
开发者ID:drawcode,项目名称:python_toolbox,代码行数:13,代码来源:emitter.py


示例9: test_function_in_main

def test_function_in_main():
    '''Test that a function defined in `__main__` is well-described.'''

    ###########################################################################
    # We can't really define a function in `__main__` in this test, so we
    # emulate it:
    with TempValueSetter((globals(), '__name__'), '__main__'):
        def f(x):
            pass
        
        # Accessing `f.__module__` here so PyPy will calculate it:
        assert f.__module__ == '__main__'
        
    assert f.__module__ == '__main__'
    import __main__
    __main__.f = f
    del __main__
    #
    ###########################################################################
    
    assert describe(f) == '__main__.f'
    assert resolve(describe(f)) is f
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:22,代码来源:test_describe.py


示例10: test_on_locally_defined_class

def test_on_locally_defined_class():
    
    ###########################################################################
    # Testing for locally defined class:
    
    
    raise nose.SkipTest("This test doesn't currently pass because `describe` "
                        "doesn't support nested classes yet.")
    
    result = describe(A.B)
    assert result == prefix + 'A.B'
    assert resolve(result) is A.B
    
    result = describe(A.C.D.deeper_method)
    assert result == prefix + 'A.C.D.deeper_method'
    assert resolve(result) == A.C.D.deeper_method
    
    result = describe(A.C.D.deeper_method, root=A.C)
    assert result == 'C.D.deeper_method'
    assert resolve(result, root=A.C) == A.C.D.deeper_method
    
    result = describe(A.C.D.deeper_method, root='A.C.D')
    assert result == 'D.deeper_method'
    assert resolve(result, root='A.C.D') == A.C.D.deeper_method
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:24,代码来源:test_describe.py


示例11: test_on_ignore_confusing_namespace

def test_on_ignore_confusing_namespace():
    '''Test that `describe` doesn't use a confusing namespace item.'''
    import email.encoders
    import marshal
    
    result = describe(
        email,
        shorten=True,
        namespace={'e': email}
    )
    assert result == 'email' # Not shortening to 'e', that would be confusing.
    
    result = describe(
        email.encoders,
        namespace={'e': email, 'email': email}
    )
    assert result == 'email.encoders'
    
    result = describe(
        email.encoders,
        root=marshal,
        namespace={'e': email, 'email': email}
    )
    assert result == 'email.encoders'
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:24,代码来源:test_describe.py


示例12: test_bad_module_name

def test_bad_module_name():
    '''
    Test `describe` works for objects with bad `__module__` attribute.
    
    The `__module__` attribute usually says where an object can be reached. But
    in some cases, like when working in a shell, you can't really access the
    objects from that non-existant module. So `describe` must not fail for
    these cases.
    '''
    
    import email

    non_sensical_module_name = '__whoop_dee_doo___rrrar'
    
    my_locals = locals().copy()
    my_locals['__name__'] = non_sensical_module_name
    
    exec 'def f(): pass' in my_locals
    exec ('class A(object):\n'
          '    def m(self): pass\n') in my_locals
    
    f, A = my_locals['f'], my_locals['A']
    
    assert describe(f) == \
        '.'.join((non_sensical_module_name, 'f'))
    assert describe(f, shorten=True, root=email, namespace={}) == \
        '.'.join((non_sensical_module_name, 'f'))
    
    assert describe(A) == \
        '.'.join((non_sensical_module_name, 'A'))
    assert describe(A, shorten=True, root=email, namespace={}) == \
        '.'.join((non_sensical_module_name, 'A'))
    
    assert describe(A.m) == \
        '.'.join((non_sensical_module_name, 'A.m'))
    assert describe(A.m, shorten=True, root=email, namespace={}) == \
        '.'.join((non_sensical_module_name, 'A.m'))
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:37,代码来源:test_describe.py


示例13: test_function_in_something

def test_function_in_something():
    '''Test `describe` doesn't fail when describing `{1: sum}`.'''
    raise nose.SkipTest("This test doesn't pass yet.")
    assert describe({1: sum}) == '{1: sum}'
    assert describe((sum, sum, list, chr)) == '(sum, sum, list, chr)'
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:5,代码来源:test_describe.py


示例14: test_multiprocessing_lock

def test_multiprocessing_lock():
    '''Test `describe` works for `multiprocessing.Lock()`.'''
    import multiprocessing
    lock = multiprocessing.Lock()
    describe(lock)
开发者ID:cool-RR,项目名称:python_toolbox,代码行数:5,代码来源:test_describe.py



注:本文中的python_toolbox.address_tools.describe函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python address_tools.resolve函数代码示例发布时间:2022-05-27
下一篇:
Python QtGui.QWidget类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap