Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'board.': 0.05; 'attribute': 0.07; 'explicit': 0.07; 'decorator': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrapped': 0.09; 'def': 0.12; 'jan': 0.12; 'attribute:': 0.16; 'func': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "d'aprano": 0.31; 'steven': 0.31; 'class': 0.32; 'add': 0.35; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'received:173': 0.61; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Skipping decorators in unit tests Date: Fri, 11 Oct 2013 04:23:57 -0400 References: <525768a5$0$29984$c3e8da3$5496439d@news.astraweb.com> <5257802f$0$29984$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: <5257802f$0$29984$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381479856 news.xs4all.nl 15883 [2001:888:2000:d::a6]:33654 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56660 On 10/11/2013 12:36 AM, Steven D'Aprano wrote: > I also like Terry Reedy's suggestion of having the decorator > automatically add the unwrapped function to the wrapped function as an > attribute: > > def decorate(func): > @functools.wraps(func) > def inner(arg): > blah blah > inner._unwrapped = func # make it public if you prefer > return inner > > which makes it all nice and clean and above board. (I seem to recall a > proposal to have functools.wraps do this automatically...) The explicit attribute can also be set by class rather than closure based decorators. -- Terry Jan Reedy