コード例 #1
0
ファイル: test_python_utils.py プロジェクト: yaelmi3/slash
def test_resolve_underlying_decorator_method():
    class Blap(object):
        def orig(self):
            pass

        decorated = _example_decorator(orig)

    assert resolve_underlying_function(
        Blap.decorated) is resolve_underlying_function(Blap.orig)
    assert resolve_underlying_function(Blap.decorated).__name__ == 'orig'
コード例 #2
0
ファイル: test_python_utils.py プロジェクト: yaelmi3/slash
def test_resolve_underlying_function_method(class_method):
    if class_method:
        decorator = classmethod
    else:
        decorator = lambda f: f

    class Blap(object):
        @decorator
        def method(self):
            pass

    resolved = resolve_underlying_function(Blap.method)
    assert resolved is resolve_underlying_function(Blap.method)  # stable
    assert not hasattr(resolved, '__func__')
    assert resolved.__name__ == 'method'
コード例 #3
0
def test_resolve_underlying_decorator_regular_func():

    def orig():
        pass
    decorated = _example_decorator(orig)
    assert resolve_underlying_function(decorated) is orig
コード例 #4
0
def test_resolve_underlying_function_method_no_op(thing):
    assert resolve_underlying_function(thing) is thing