Coverage tracking for the test suite.
If you issue `make test`, it will run the tests and print out a coverage reporting indicating what lines of code were covered by the tests and which were not. This will (hopefully) be useful more over time as we start to write more tests.
This commit is contained in:
parent
97e85a17b1
commit
f475b92802
6 changed files with 9 additions and 32 deletions
5
.coveragerc
Normal file
5
.coveragerc
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[run]
|
||||
|
||||
omit =
|
||||
/usr/lib/*
|
||||
tests/*
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
*.pyc
|
||||
*.pyo
|
||||
tests/test.py
|
||||
.coverage
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -63,6 +63,9 @@ clean:
|
|||
git-clean:
|
||||
@git clean -d -q -x
|
||||
|
||||
test:
|
||||
nosetests --with-coverage --cover-package .
|
||||
|
||||
subdirs:
|
||||
for d in $(SUBDIRS); do make -C $$d; [ $$? = 0 ] || exit 1; done
|
||||
|
||||
|
|
|
|||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
|
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""Wrapper script for running unit tests"""
|
||||
|
||||
__version__ = "$Revision: 1.1 $"
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import unittest
|
||||
|
||||
testDir = os.path.dirname(sys.argv[0])
|
||||
|
||||
sys.path.insert(0, os.path.abspath('%s/..' % testDir))
|
||||
|
||||
allTests = unittest.TestSuite()
|
||||
for root, dirs, files in os.walk(testDir):
|
||||
common_path = os.path.commonprefix([os.path.abspath(testDir),
|
||||
os.path.abspath(root)])
|
||||
root_path = os.path.abspath(root).replace(common_path, '').lstrip('/').replace('/', '.')
|
||||
|
||||
for test_file in [item for item in files
|
||||
if item.startswith("test_") and item.endswith(".py")]:
|
||||
if len(sys.argv) == 1 or test_file in sys.argv[1:]:
|
||||
print "adding %s..." % test_file
|
||||
test_file = test_file[:-3]
|
||||
if root_path:
|
||||
test_file = "%s.%s" % (root_path, test_file)
|
||||
suite = unittest.defaultTestLoader.loadTestsFromName(test_file)
|
||||
allTests.addTests(suite._tests)
|
||||
|
||||
unittest.TextTestRunner(verbosity=2).run(allTests)
|
||||
Loading…
Add table
Add a link
Reference in a new issue