Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56661

Re: Skipping decorators in unit tests

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'true,': 0.05; '(of': 0.07; 'filing': 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; 'def': 0.12; 'jan': 0.12; '"""return': 0.16; '201': 0.16; 'function?': 0.16; 'portable': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'robust.': 0.16; 'simpson': 0.16; 'stdlib.': 0.16; 'wrote:': 0.18; 'module': 0.19; 'skip:f 30': 0.19; 'later': 0.20; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'requirement.': 0.24; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'convince': 0.31; "d'aprano": 0.31; 'steven': 0.31; "i'd": 0.34; 'but': 0.35; "i'll": 0.36; 'so,': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'black': 0.61; 'received:173': 0.61; 'first': 0.61; 'received:fios.verizon.net': 0.84; 'not:': 0.91; 'whereas': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Skipping decorators in unit tests
Date Fri, 11 Oct 2013 04:25:41 -0400
References <525768a5$0$29984$c3e8da3$5496439d@news.astraweb.com> <20131011031319.GA30742@cskk.homeip.net> <l38c6t$g26$1@ger.gmane.org>
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 <l38c6t$g26$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.993.1381480211.18130.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381480211 news.xs4all.nl 15888 [2001:888:2000:d::a6]:36528
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56661

Show key headers only | View raw


On 10/11/2013 4:17 AM, Terry Reedy wrote:
> On 10/10/2013 11:13 PM, Cameron Simpson wrote:
>> On 11Oct2013 02:55, Steven D'Aprano
>> <steve+comp.lang.python@pearwood.info> wrote:
>
>>> def undecorate(f):
>>>      """Return the undecorated inner function from function f."""
>>>      return f.func_closure[0].cell_contents
>>
>> Whereas this feels like black magic. Is this portable to any decorated
>> function? If so, I'd have hoped it was in the stdlib. If not: black
>> magic.
>>
>>> And in use:
>>>
>>> py> f(100)
>>> 201
>>> py> undecorate(f)(100)
>>> 200
>>
>> All lovely, provided you can convince me that undecorate() is robust.
>> (And if you can, I'll certainly be filing it away in my funcutils
>> module for later use.)
>
> It only works if the decorator returns a closure with the original
> function as the first member (of func_closure). Often true, but not at
> all a requirement.
>


-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Skipping decorators in unit tests Gilles Lenfant <gilles.lenfant@gmail.com> - 2013-10-10 07:00 -0700
  Re: Skipping decorators in unit tests Cameron Simpson <cs@zip.com.au> - 2013-10-11 09:12 +1100
    Re: Skipping decorators in unit tests Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-11 02:55 +0000
      Re: Skipping decorators in unit tests Cameron Simpson <cs@zip.com.au> - 2013-10-11 14:13 +1100
        Re: Skipping decorators in unit tests Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-11 04:36 +0000
          Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-11 04:23 -0400
      Re: Skipping decorators in unit tests Ben Finney <ben+python@benfinney.id.au> - 2013-10-11 14:42 +1100
      Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-11 04:17 -0400
      Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-11 04:25 -0400
      Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-11 04:32 -0400
      Re: Skipping decorators in unit tests Ethan Furman <ethan@stoneleaf.us> - 2013-10-11 10:51 -0700
  Re: Skipping decorators in unit tests Ned Batchelder <ned@nedbatchelder.com> - 2013-10-10 19:44 -0400
  Re: Skipping decorators in unit tests Terry Reedy <tjreedy@udel.edu> - 2013-10-10 21:12 -0400
  Re: Skipping decorators in unit tests Gilles Lenfant <gilles.lenfant@gmail.com> - 2013-10-11 02:37 -0700
    Re: Skipping decorators in unit tests Cameron Simpson <cs@zip.com.au> - 2013-10-12 08:38 +1100

csiph-web