Hi Anto, On Thu, Oct 11, 2012 at 22:10 +0200, Antonio Cuni wrote: > 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.
I agree that is one way to solve it. However, if "hiding" the function can be avoided alltogether, then it's even better. On a sidenote, i am not sure Python's decorator design was such a great idea. Maybe it should have been restricted to setting attributes (like C# and also java IIRC) and then a way to get those attributed functions on a per-class, per-module or even global basis. best, holger _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev