How do I generate coverage xml report for a single package?

2024/9/24 18:22:37

I'm using nose and coverage to generate coverage reports. I only have one package right now, ae, so I specify to only cover that:

nosetests -w tests/unit --with-xunit --with-coverage --cover-package=ae

And here are the results, which look good:

Name             Stmts   Exec  Cover   Missing
----------------------------------------------
ae                   1      1   100%   
ae.util            253    224    88%   39, 63-65, 284, 287, 362, 406
----------------------------------------------
TOTAL              263    234    88%   
----------------------------------------------------------------------
Ran 68 tests in 5.292s

However when I run coverage xml, coverage pulls in more packages than necessary, including python email and logging packages which have nothing to do with my code.

If I run coverage xml ae, I get this error:

No source for code: '/home/wraith/dev/projects/trimurti/src/ae': 
[Errno 21] Is a directory: '/home/wraith/dev/projects/trimurti/src/ae'

Is there a way to generate the XML for just the ae package?

Answer

I had a similar problem and solved it with the --omit option. This made it run much faster and reduced the size of coverage.xml from 2MB to 70kB.

--omit=PRE1,PRE2,...  Omit files when their filename path starts with one ofthese prefixes.

I'm on Mac OS X, so I omitted the /Library/ and /Applications/ folders:

$ coverage xml --omit=/Library/,/Applications/

On other systems, you may find --omit=/usr/ more helpful.

https://en.xdnf.cn/q/71673.html

Related Q&A

Asynchronous URLfetch when we dont care about the result? [Python]

In some code Im writing for GAE I need to periodically perform a GET on a URL on another system, in essence pinging it and Im not terribly concerned if the request fails, times out or succeeds.As I bas…

Python: How to fill out form all at once with splinter/Browser?

Currently, I’m filling out the form on a site with the following:browser.fill(‘form[firstname]’, ‘Mabel’) browser.fill(‘form[email]’, ‘[email protected]’) browser.select(‘form[color]’, ‘yel…

Dump elementtree into xml file

I created an xml tree with something like thistop = Element(top) child = SubElement(top, child) child.text = some texthow do I dump it into an XML file? I tried top.write(filename), but the method doe…

Crash reporting in Python

Is there a crash reporting framework that can be used for pure Python Tkinter applications? Ideally, it should work cross-platform.Practically speaking, this is more of exception reporting since the P…

Python SocketServer

How can I call shutdown() in a SocketServer after receiving a certain message "exit"? As I know, the call to serve_forever() will block the server.Thanks!

Loading JSON file in BigQuery using Google BigQuery Client API

Is there a way to load a JSON file from local file system to BigQuery using Google BigQuery Client API?All the options I found are:1- Streaming the records one by one.2- Loading JSON data from GCS.3- …

How to extract tables from a pdf with PDFMiner?

I am trying to extract information from some tables in a pdf document. Consider the input:Title 1 some text some text some text some text some text some text some text some text some text some textTabl…

Draw Box-Plot with matplotlib

Is it possible to plot this kind of chart with matplotlib?

Why I get urllib2.HTTPError with urllib2 and no errors with urllib?

I have the following simple code:import urllib2 import sys sys.path.append(../BeautifulSoup/BeautifulSoup-3.1.0.1) from BeautifulSoup import * page=http://en.wikipedia.org/wiki/Main_Page c=urllib2.urlo…

python - replace the boolean value of a list with the values from two different lists [duplicate]

This question already has answers here:Merge two or more lists with given order of merging(2 answers)Closed 6 years ago.I have one list with boolean values likelyst = [True,True,False,True,False]and tw…