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


Groups > comp.lang.python > #56701

Re: Skipping decorators in unit tests

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.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 <ethan@stoneleaf.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'here?': 0.09; 'message-id:@stoneleaf.us': 0.09; '~ethan~': 0.09; 'def': 0.12; '"""return': 0.16; 'b):': 0.16; 'function?': 0.16; 'language:': 0.16; 'losing': 0.16; 'portable': 0.16; 'simpson': 0.16; 'stdlib.': 0.16; 'syntax,': 0.16; 'folks': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'skip:f 30': 0.19; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'decorators': 0.24; 'this:': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'testing': 0.29; "d'aprano": 0.31; 'steven': 0.31; 'probably': 0.32; 'stuff': 0.32; 'fri,': 0.33; "i'd": 0.34; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'should': 0.36; 'unit': 0.37; 'so,': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'aside': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'easy': 0.60; 'black': 0.61; 'simple': 0.61; "you're": 0.61; 'provide': 0.64; 'received:gateway15.websitewelcome.com': 0.84; 'not:': 0.91; 'whereas': 0.91; '2013': 0.98
Date Fri, 11 Oct 2013 10:51:01 -0700
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: Skipping decorators in unit tests
References <525768a5$0$29984$c3e8da3$5496439d@news.astraweb.com> <20131011031319.GA30742@cskk.homeip.net>
In-Reply-To <20131011031319.GA30742@cskk.homeip.net>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - gator3304.hostgator.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - stoneleaf.us
X-BWhitelist no
X-Source
X-Source-Args
X-Source-Dir
X-Source-Sender ([192.168.1.115]) [50.39.86.194]:40091
X-Source-Auth ethan+stoneleaf.us
X-Email-Count 7
X-Source-Cap dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20=
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.1012.1381517509.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381517509 news.xs4all.nl 16002 [2001:888:2000:d::a6]:36844
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56701

Show key headers only | View raw


On 10/10/2013 08:13 PM, Cameron Simpson wrote:
> On 11Oct2013 02:55, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote:
>> On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote:
>>> Speaking for myself, I would be include to recast this code:
>>>
>>>    @absolutize
>>>    def addition(a, b):
>>>        return a + b
>>>
>>> into:
>>>
>>>    def _addition(a, b):
>>>        return a + b
>>>    addition = absolutize(_addition)
>>>
>>> Then you can unit test both _addition() and addition().
>>
>> *shudders*
>> Ew ew ew ew.
>
> Care to provide some technical discourse here? Aside from losing the neat
> and evocative @decorator syntax, the above is simple and overt.

And completely dismisses the whole point of adding @decorator to the 
language:  easy to use, easy to see == folks will actually use it.

>> I would much rather do something like this:
>>
>> 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.

Probably black magic.  But you can go with the decorator.wrapped route; 
after all, you're testing your own stuff so you should have control of 
your own decorators (okay, you may have to adapt a few others ;) .

--
~Ethan~

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