Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'decorator': 0.09; 'cc:addr :python-list': 0.11; 'def': 0.12; 'bug': 0.12; 'b):': 0.16; 'behave': 0.16; 'reasonable.': 0.16; 'simpson': 0.16; 'situation.': 0.16; 'suite.': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'all,': 0.19; '>>>': 0.22; '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; '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; 'service,': 0.32; '(i.e.': 0.33; 'cc:no real name:2**1': 0.33; 'core': 0.34; 'something': 0.35; 'case,': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'functions.': 0.36; "he's": 0.36; 'should': 0.36; 'unit': 0.37; 'skip:o 20': 0.38; 'desirable': 0.38; 'pm,': 0.38; 'how': 0.40; 'skip:u 10': 0.60; "you're": 0.61; 'kind': 0.63; 'more': 0.64; 'here': 0.66; 'direct': 0.67; 'therefore': 0.72; 'anyone.': 0.74; 'batchelder': 0.84; 'lucky': 0.93; 'wanting': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=kktR57Rv3z4J0zItJaiaIfk0geT4tgSLL3nVz/k90pc=; b=AF0KnGHJd0CiY15Gvi5VVJq2zy+bKkWURBW0FgjRBqtnXAuPgoyc4qsp8+JPwpepUd g4zbOqXt9kdtrqKMEUgDS+vsMh4wBTw5vjB8Ij8f7T7vP+E8xAcddSswgVApMSh4CtVb g7iY1Kh/r14wS+i8yena88Dr69BgxmNcxnJjJeeAek9KteBLVFG/XcwXQglgEiAxC9xl Gu39BiDlHTXLUGcLj5ljYW8Z2FWNlIKyg/VXb0iHHcnISWN4q6JuUEmHsFOjsGmx01LY 4I7XnLgsa++jyNPqK0DJFeVqNxwUtTLtBVI4YEPLyvfgG+UaBWT4epBo+G7epPXULcHv X0MA== X-Received: by 10.49.94.72 with SMTP id da8mr9853532qeb.67.1381517605839; Fri, 11 Oct 2013 11:53:25 -0700 (PDT) Sender: Ned Batchelder Date: Fri, 11 Oct 2013 14:53:24 -0400 From: Ned Batchelder User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Cameron Simpson Subject: Re: Skipping decorators in unit tests References: <52573BED.40305@nedbatchelder.com> <20131011022218.GA97623@cskk.homeip.net> In-Reply-To: <20131011022218.GA97623@cskk.homeip.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381517615 news.xs4all.nl 15874 [2001:888:2000:d::a6]:38913 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56702 On 10/10/13 10:22 PM, Cameron Simpson wrote: > On 10Oct2013 19:44, Ned Batchelder 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, I understand the desire to test the inner function. But the OP said "I need to...", which makes me think he's dealing with some kind of "mock a service, but the service is in the decorator, so what should I do?" situation. In which case, there might be a better solution than undecorating the function. --Ned.