excluding packages/directories

726 views
Skip to first unread message

Nikola Skoric

unread,
Jun 24, 2010, 4:12:50 PM6/24/10
to nose-users
How do I exclude certain packages from being displayed in report? I figured out that in coverage I do it with --omit flag, but can't figure it out in nosetests. Nose in it's report lists several packages I didn't even know I use (albeit listing them as 0% tested, which is good) and that clutters the report and slows my workflow. Here is my test session:

nick@rilmir:~/code/travapi$ cat runtest.sh                                                  
#!/bin/bash                                                                                 
export PYTHONPATH=$PYTHONPATH:~/code/travapi/travapi/
echo "Runing nosetests..."                          
nosetests --with-coverage                           
echo "Creating coverage HTML report..."             
coverage html                                       
echo "Done."                                        
nick@rilmir:~/code/travapi$ ./runtest.sh            
Runing nosetests...                                 
..............                                      
Name                       Stmts   Exec  Cover   Missing
--------------------------------------------------------
_LWPCookieJar                 93      0     0%   14-169
_MozillaCookieJar             68      0     0%   3-149 
account                       63     60    95%   11, 97, 102
calendar                     373      0     0%   8-704     
[... whole lot of everything ...]
--------------------------------------------------------                                    
TOTAL                       5703    474     8%                                              
--------------------------------------------------------
Ran 14 tests in 11.487s                                                                     

OK
Creating coverage HTML report...
Done.                          
nick@rilmir:~/code/travapi$ cat .coveragerc
[report]
exclude_lines =
    #nocov
    def __repr__
    def __str__

omit = /usr/local/lib/python2.6/dist-packages
nick@rilmir:~/code/travapi$ coverage report
Name                  Stmts   Exec  Cover
-----------------------------------------
test/test_account        13     13   100%
[... my tests ...]
test/test_village        25     25   100%
travapi/__init__          1      1   100%
[... my package ...]
travapi/village         132    121    91%
-----------------------------------------
TOTAL                   610    568    93%
nick@rilmir:~/code/travapi$

So, coverage got it all right when I set the "omit" flag. Is there a way to make nose forget about all those standard libraries and stuff from my dist-packages?

Kind regards,
Nikola

--
"Strange women lying in ponds distributing swords is no basis for a system of government."

Ned Batchelder

unread,
Jun 24, 2010, 8:56:52 PM6/24/10
to nose-...@googlegroups.com, Nikola Skoric
Nikola, I think you are confusing what nose does and what coverage.py
does. Nose does one thing: finds tests and runs them. Coverage.py does
another thing: measures code execution and reports what it finds. The
modules you see in the coverage report are really executed, and nothing
you tell nose will make them not be executed. _LWPCookieJar is a module
that is somehow eventually imported by your tests. I don't quite
understand the 0% coverage, but it isn't a nose issue.

--Ned.

> --
> You received this message because you are subscribed to the Google
> Groups "nose-users" group.
> To post to this group, send email to nose-...@googlegroups.com.
> To unsubscribe from this group, send email to
> nose-users+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nose-users?hl=en.

Nikola Skoric

unread,
Jun 24, 2010, 10:25:51 PM6/24/10
to Ned Batchelder, nose-...@googlegroups.com
OK, let me rephrase the problem: when I run "nosetests --with-coverage" from shell, "nosetests --with-coverage" returns me a report that has some libraries in it which I don't want to see there. How do I remove them from there (be it coverage problem or nose problem or whatever)?

It's just that what "nosetests --with-coverage" returns to me is full of data I'm not interested in and I'd like to see that data out or my everyday life. If the answer is "you can't get it our", no problemo, I can live with that. I just had to ask :-)

Sorry for being pain in the ass :-D

Regards,
Nikola

Paul Joseph Davis

unread,
Jun 24, 2010, 11:53:37 PM6/24/10
to nose-...@googlegroups.com
The nose plugin for coverage has an option like --cover-package that you can use to white list the modules you're interested in seeing in your report.

HTH,
Paul Davis

Ned Batchelder

unread,
Jun 25, 2010, 6:59:24 AM6/25/10
to Nikola Skoric, nose-...@googlegroups.com
You can omit packages from reporting in coverage.py with the omit option in the .coveragerc file.  The odd thing here is that the modules reported as 0% are all stdlib modules.  They must have been imported before coverage measurement started to have 0% coverage.  If you run coverage outside of nose (with "coverage run nosetests-script.py ..."), the problem will likely go away, though you may have other difficulties.

--Ned.

Nikola Skoric

unread,
Jun 25, 2010, 9:37:32 AM6/25/10
to nose-...@googlegroups.com
I tired that before and it didn't work... but it didn't work because I used relative path. Now I used absolute path to my package and now everything works like a charm.

Thank you Paul and Ned for being so helpful, I hope one day I will also be able to contribute to world of free software and help somebody else :-)

Regards,
Nikola


On 25 June 2010 05:53, Paul Joseph Davis <paul.jos...@gmail.com> wrote:
The nose plugin for coverage has an option like --cover-package that you can use to white list the modules you're interested in seeing in your report.

HTH,
Paul Davis

Reply all
Reply to author
Forward
0 new messages