Example #1
0
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'
Example #2
0
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'
Example #3
0
def test_resolve_underlying_decorator_regular_func():

    def orig():
        pass
    decorated = _example_decorator(orig)
    assert resolve_underlying_function(decorated) is orig
Example #4
0
def test_resolve_underlying_function_method_no_op(thing):
    assert resolve_underlying_function(thing) is thing