How do I make pytest fixtures work with decorated functions?

It looks like functools.wraps does not do the job well enough, so it breaks py.test’s introspection.

Creating the decorator using the decorator package seems to do the trick.

import decorator

def deco(func):
    def wrapper(func, *args, **kwargs):
        return func(*args, **kwargs)
    return decorator.decorator(wrapper, func)

Leave a Comment