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


Groups > comp.lang.python > #57481

Re: Python Coverage: testing a program

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 <nedbat@gmail.com>
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 <nedbat@gmail.com>
Date Thu, 24 Oct 2013 19:53:44 -0400
From Ned Batchelder <ned@nedbatchelder.com>
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 <ethan@stoneleaf.us>, 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> <mailman.1463.1382611399.18130.python-list@python.org> <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 <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.1490.1382658834.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On 10/24/13 6:28 PM, Ethan Furman wrote:
> On 10/24/2013 01:54 PM, Ben Finney wrote:
>> Terry Reedy <tjreedy@udel.edu> 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
>> <URL:http://nedbatchelder.com/code/coverage/excluding.html> 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~
>
>

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


Thread

Maintaining a backported module Steven D'Aprano <steve@pearwood.info> - 2013-10-24 04:54 +0000
  Re: Maintaining a backported module Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 16:09 +1100
    Re: Maintaining a backported module Metallicow <metaliobovinus@gmail.com> - 2013-10-23 22:46 -0700
      Re: Maintaining a backported module Metallicow <metaliobovinus@gmail.com> - 2013-10-30 03:32 -0700
  Re: Maintaining a backported module Paul Rubin <no.email@nospam.invalid> - 2013-10-23 22:38 -0700
  Re: Maintaining a backported module Ethan Furman <ethan@stoneleaf.us> - 2013-10-23 23:30 -0700
  Re: Maintaining a backported module Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 17:59 +1100
    Re: Maintaining a backported module Steven D'Aprano <steve@pearwood.info> - 2013-10-24 09:38 +0000
      Re: Maintaining a backported module Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 21:01 +1100
  Re: Maintaining a backported module Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-24 09:00 +0200
  Re: Maintaining a backported module Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-24 09:37 +0100
  Re: Maintaining a backported module Ned Batchelder <ned@nedbatchelder.com> - 2013-10-24 06:36 -0400
    Re: Maintaining a backported module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-24 11:46 +0000
      Re: Maintaining a backported module rusi <rustompmody@gmail.com> - 2013-10-24 05:25 -0700
      Re: Maintaining a backported module Ned Batchelder <ned@nedbatchelder.com> - 2013-10-24 13:46 -0400
      Re: Maintaining a backported module Terry Reedy <tjreedy@udel.edu> - 2013-10-24 16:37 -0400
      Python Coverage: testing a program (was: Maintaining a backported module) Ben Finney <ben+python@benfinney.id.au> - 2013-10-25 07:54 +1100
      Re: Python Coverage: testing a program Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-24 22:55 +0100
      Re: Python Coverage: testing a program Terry Reedy <tjreedy@udel.edu> - 2013-10-24 18:36 -0400
      Re: Python Coverage: testing a program Ethan Furman <ethan@stoneleaf.us> - 2013-10-24 15:28 -0700
      Re: Python Coverage: testing a program Ben Finney <ben+python@benfinney.id.au> - 2013-10-25 10:27 +1100
      Re: Python Coverage: testing a program Ben Finney <ben+python@benfinney.id.au> - 2013-10-25 10:30 +1100
      Re: Python Coverage: testing a program Ned Batchelder <ned@nedbatchelder.com> - 2013-10-24 19:53 -0400
      Re: Python Coverage: testing a program Terry Reedy <tjreedy@udel.edu> - 2013-10-24 19:55 -0400
      Re: Maintaining a backported module Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-25 08:49 +0100
  Re: Maintaining a backported module Christian Heimes <christian@python.org> - 2013-10-24 12:47 +0200
  Re: Maintaining a backported module Ethan Furman <ethan@stoneleaf.us> - 2013-10-24 12:42 -0700

csiph-web