2011/5/30 Vyacheslav Rafalskiy <rafals...@gmail.com>: > Hi Holger, > > I am trying to make decorators work with test functions, which depend > on funcargs. As it stands, they don't. > Decorated functions lose funcargs. A workaround would be to decorate > an internal function like this: > > def test_it(funcarg_it): > @decorate_it > def _test_it(): > # test it > > _test_it() > > This works, but it is not nice. I'd rather wrote a decorator like > > def decorate_it(f): > def _wrap_it(*args, **kwargs): > # wrap f() here > > _wrap_it._varnames = _pytest.core.varnames(f) > return _wrap_it > > and apply it straight to the test function. > > After examining the source code I even expected it to just work > (magically of course) but it didn't. > Do you think it is worthwhile? If so I can enter a feature request.
It's a difficult problem because there's no way to know if a function is being decorated. I suppose py.test could look for a _decorated_ attribute but decorators would have to conform and set that attribute. -- Regards, Benjamin _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev