Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'report.': 0.07; '"if': 0.09; '__name__': 0.09; 'items)': 0.09; 'sure,': 0.09; '~ethan~': 0.09; 'times,': 0.14; '(apologies': 0.16; 'clauses': 0.16; 'coverage?': 0.16; 'finney': 0.16; 'reedy': 0.16; 'statements,': 0.16; 'subject:program': 0.16; 'files.': 0.16; 'ignore': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; '>>>': 0.22; 'appears': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'url:code': 0.29; "i'm": 0.30; '>>>>': 0.31; 'exclude': 0.31; 'writes:': 0.31; 'run': 0.32; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'coverage': 0.36; 'ben': 0.38; 'question,': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'reported': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'tell': 0.60; 'myself': 0.63; 'different': 0.65; 'programs,': 0.74; '100%': 0.77; 'batchelder': 0.84; 'ethan': 0.84; 'furman': 0.84; 'request:': 0.91 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:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=LFH+paHQXwnNKpCZT+nN/IkxbxMIFJ2XG/kjcWi6708=; b=pksIowc+C0VG7VSa7nlL/aAl510/gzqQFV5wzQ2X6Le76ciP2Agbtyfsw6LhLFhe5R eGX/5wbPCEuVn/GOw8DXnDlgfktNY9XSOQ8zcBblxQd+fCQJKtLEJiiHZuIxxspwMjXm 1CDZ7QlV7UL39Ra9md0hPiBArG8Xmu5N2Eu0aXXmsqi2TfCFeNi0mqNuC4JwI1c40wgs UhlIfTtPKeLutk3Vl8YgcrfKL21v36NRdwApnewZYYSz71i6Xaj272iQmqeYJ74e/WVs KOrJUgd0JxHtetVfgFE9n7sfIMxekG5C1CtiqMovgwRwypNeSIRyk5eHTylO8MHuIvIo Zyhw== X-Received: by 10.224.114.147 with SMTP id e19mr7427358qaq.21.1382658826487; Thu, 24 Oct 2013 16:53:46 -0700 (PDT) Sender: Ned Batchelder Date: Thu, 24 Oct 2013 19:53:44 -0400 From: Ned Batchelder User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Ethan Furman , python-list@python.org Subject: Re: Python Coverage: testing a program References: <5268a818$0$30000$c3e8da3$5496439d@news.astraweb.com> <7wtxg7cfww.fsf@benfinney.id.au> <526908b2$0$29981$c3e8da3$5496439d@news.astraweb.com> <52695CFB.9010309@nedbatchelder.com> <526984F3.3040905@udel.edu> <7weh7acrv8.fsf_-_@benfinney.id.au> <52699EFE.3070904@stoneleaf.us> In-Reply-To: <52699EFE.3070904@stoneleaf.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382658834 news.xs4all.nl 15959 [2001:888:2000:d::a6]:47755 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57481 On 10/24/13 6:28 PM, Ethan Furman wrote: > On 10/24/2013 01:54 PM, Ben Finney wrote: >> Terry Reedy writes: >> >>> On 10/24/2013 1:46 PM, Ned Batchelder wrote: >>>> It's been fun dropping the contortions for coverage.py 4.x, though! >>> >>> One request: ignore "if __name__ == '__main__':" clauses at the end of >>> files, which cannot be run under coverage.py, so 100% coverage is >>> reported as 100% instead of 9x%. >> >> You can do this already with current Coverage: tell Coverage to exclude >> specific >> statements, and it won't count them for coverage calculations. > > While that's neat (being able to exclude items) is there any reason to > ever count the `if __name__ == '__main__'` clause? Are there any > circumstances where it could run under Coverage? (Apologies if this is > a dumb question, I know nothing about Coverage myself -- but I'm going > to go look it up now. ;) > Sure, if that line appears in program.py, then it will be run if you execute program.py: $ coverage run program.py You can run coverage a number of times, even with different main programs, then combine all the data to produce a combined report. This way you could cover all of the __main__ clauses in a number of files. --Ned. > -- > ~Ethan~ > >