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


Groups > comp.lang.python > #56635

Re: Skipping decorators in unit tests

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'decorator': 0.09; "they've": 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'bug': 0.12; 'b):': 0.16; 'behave': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'reasonable.': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'suite.': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'cc:addr:gmail.com': 0.22; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'header:User- Agent:1': 0.23; 'error': 0.23; "aren't": 0.24; "shouldn't": 0.24; 'simpler': 0.24; 'cheers,': 0.24; 'code:': 0.26; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'points': 0.29; 'especially': 0.30; "i'm": 0.30; '(i.e.': 0.33; 'cc:no real name:2**1': 0.33; 'core': 0.34; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'functions.': 0.36; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'unit': 0.37; 'skip:o 20': 0.38; 'desirable': 0.38; 'received:211': 0.38; 'pm,': 0.38; 'how': 0.40; 'skip:u 10': 0.60; 'new': 0.61; "you're": 0.61; 'content-disposition:inline': 0.62; 'more': 0.64; 'here': 0.66; 'direct': 0.67; 'therefore': 0.72; 'anyone.': 0.74; 'batchelder': 0.84; 'nuclear': 0.84; 'weapons': 0.84; 'lucky': 0.93; 'wanting': 0.93
Date Fri, 11 Oct 2013 13:22:18 +1100
From Cameron Simpson <cs@zip.com.au>
To Ned Batchelder <ned@nedbatchelder.com>
Subject Re: Skipping decorators in unit tests
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <52573BED.40305@nedbatchelder.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <52573BED.40305@nedbatchelder.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=DstvpgP+ c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=MIEZmskQDU0A:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=AS59is4VRK8A:10 a=W4ub2mWhAAAA:8 a=-RUyio1xWAPBcIxx3AsA:9 a=CjuIK1q_8ugA:10 a=0xq-cdXUTwIA:10
Cc gilles.lenfant@gmail.com, python-list@python.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.978.1381459605.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381459605 news.xs4all.nl 15883 [2001:888:2000:d::a6]:58817
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56635

Show key headers only | View raw


On 10Oct2013 19:44, Ned Batchelder <ned@nedbatchelder.com> wrote:
> On 10/10/13 6:12 PM, 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(). [...]
> 
> I have to admit I'm having a hard time understanding why you'd need
> to test the undecorated functions.  After all, the undecorated
> functions aren't available to anyone.  All that matters is how they
> behave with the decorators.

If the undecorated function is buggy, the decorated function will
be buggy. But the bug will be harder to resolve, and if you're
especially lucky the decorator will often-but-not-always conceal
the bug in the inner function.

Wanting to test the core function is perfectly reasonable. You can in
principle write simpler and more direct tests of the core function.

Having an error report that points directly at an error instead of
an error report that points at some outer dysfunction (i.e. "somewhere
deep inside here something is broken") is highly desirable in
general, and therefore also in a test suite.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

They shouldn't get any new nuclear weapons until they've used the ones
they've got.    - Murff

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


Thread

Re: Skipping decorators in unit tests Cameron Simpson <cs@zip.com.au> - 2013-10-11 13:22 +1100
  Re: Skipping decorators in unit tests Roy Smith <roy@panix.com> - 2013-10-10 23:01 -0400
    Re: Skipping decorators in unit tests Ethan Furman <ethan@stoneleaf.us> - 2013-10-11 10:46 -0700

csiph-web