[py-dev] Using funcargs with decorators

Antonio Cuni anto.cuni at gmail.com
Thu Oct 11 22:10:09 CEST 2012


Hi Holger, Sebastian,

On 10/11/2012 03:16 PM, holger krekel wrote:
> ah, now i get it.  You want to assign the function back.
> That is indeed not going to work as pytest then sees the rollback
> function (i assume you return another function from this decorator).
> What is the decorator-returned function doing?  

I admit I did not follow the discussion deeply. However, if the problem is
that py.test sees the decorated function (which presumably uses *args and
**kwargs) instead of the original one, it can be solved by using the same
technique I used for enforceargs in pypy:

https://bitbucket.org/pypy/pypy/src/7f6d5c878b90/pypy/rlib/objectmodel.py#cl-170

in practice, the trick is to exec() a function def with the correct argument
list instead of just relying on *args, **kwargs. This way, py.test should be
able to find the correct signature.

ciao,
anto



More information about the Pytest-dev mailing list