I'm trying to wrangle nose + coverage. If I have this code:
class Foobar(object):
def add(self, a, b):
return a + b
And this test:
from unittest import TestCase
from foobar import Foobar
class FoobarTest(TestCase):
def test_good(self):
f = Foobar()
self.assertEquals(f.add(1,2), 3)
Then everything looks good!
$ nosetests
.
Name Stmts Miss Cover Missing
-----------------------------------------
foobar.py 3 0 100%
----------------------------------------------------------------------
Ran 1 test in 0.018s
OK
But if I add one line to my source code
import requests
class Foobar(object):
def add(self, a, b):
return a + b
then I get lots of extra stuff in my report
$ nosetests
.
Name Stmts Miss Cover Missing
--------------------------------------------------------------------------------------------------------
foobar.py 4 0 100%
requests.py 26 5 81% 54, 72-75
requests/adapters.py 180 134 26% 48, 51, 54, 89-102, 105, 111-117, 1
[snip]
So how do I configure coverage to say "don't bother measuring or reporting anything that is part of my virtualenv -- just do the stuff under my working directory." I'm sure it has something to do with .coveragerc, but I'm having some trouble getting the invocation correct.
Figured it out.
1) Get rid of any coverage-related ini files
2) add this in "nose.cfg" in your home directory for the nose stuff
and of course, you have to be sure that your test files match the testMatch pattern that Nose is looking for.