Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'preferably': 0.05; 'tests,': 0.09; 'def': 0.12; 'b):': 0.16; 'forth.': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'gilles': 0.16; 'heed': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'modules.': 0.16; 'opposite': 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; 'wrote:': 0.18; 'library': 0.18; 'app': 0.19; 'packages.': 0.19; 'example': 0.22; 'header:User-Agent:1': 0.23; 'decorators': 0.24; 'exists': 0.24; 'cheers,': 0.24; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; '"remove': 0.31; 'maybe': 0.34; 'classes': 0.35; 'equal': 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'unit': 0.37; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; '2nd': 0.60; 'content-disposition:inline': 0.62; '1st': 0.74; 'economist': 0.84; 'wrong!': 0.84 Date: Fri, 11 Oct 2013 09:12:38 +1100 From: Cameron Simpson To: python-list@python.org Subject: Re: Skipping decorators in unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2490050c-61d9-4bfd-bdd5-921e2f95a44b@googlegroups.com> User-Agent: Mutt/1.5.21 (2010-09-15) References: <2490050c-61d9-4bfd-bdd5-921e2f95a44b@googlegroups.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=YYGEuWhf 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=8AHkEIZyAAAA:8 a=AS59is4VRK8A:10 a=pGLkceISAAAA:8 a=fGO4tVQLAAAA:8 a=dNlk8-SL44Q066aCSvAA:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381444450 news.xs4all.nl 15888 [2001:888:2000:d::a6]:37142 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56612 On 10Oct2013 07:00, Gilles Lenfant wrote: > (explaining the title) : my app has functions and methods (and > maybe classes in the future) that are decorated by decorators > provided by the standard library or 3rd party packages. > > But I need to test "undecorated" functions and methods in my unit tests, preferably without adding "special stuffs" in my target tested modules. > > Can someone point out good practices or dedicated tools that "remove temporarily" the decorations. > I pasted a small example of what I heed at http://pastebin.com/20CmHQ7Y 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(). And so forth. Cheers, -- Cameron Simpson 1st Law Economists: For every economist there exists an equal and opposite economist. 2nd Law Economists: They're both always wrong!