Closed
Description
_pytest.compat.get_real_func
doesn't work as expected in Python 2.7:
Example:
from _pytest.compat import get_real_func
import functools
def my_decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwds):
print('Calling decorated function')
return f(*args, **kwds)
return wrapper
#@my_decorator
def example():
"""Docstring"""
print('Called example function')
decorated_example = my_decorator(example)
if get_real_func(decorated_example) is example:
print('get_real_func works')
else:
print('get_real_func fails')
Python 3.5 output:
$ python3.5 test.py
get_real_func works
Python 2.7 output:
$ python2.7 test.py
get_real_func fails
Tested with PyTest 3.0.6 though the same idea (isinstance(obj, functools.partial)
) is attempted in master
.