rework coverage calculation for coveralls.io

This commit is contained in:
Stefan Kögl 2013-07-08 11:36:42 +02:00
parent fe29c9e6cf
commit 4ed55a3fb5
4 changed files with 42 additions and 27 deletions

15
.coveragerc Normal file
View File

@ -0,0 +1,15 @@
# .coveragerc to control coverage.py
[run]
branch = True
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# No need to test __repr__
def __repr__
# Python 2/3 compatibility
except ImportError

View File

@ -5,7 +5,13 @@ python:
- "3.2"
- "3.3"
- "pypy"
# command to install dependencies
install: pip install -r requirements.txt
# command to run tests
script: nosetests tests.py
install:
- pip install -r requirements.txt
- pip install coveralls --use-mirrors
script:
- coverage run --source=jsonpatch tests.py
after_script:
- coveralls

17
makefile Normal file
View File

@ -0,0 +1,17 @@
help:
@echo "jsonpatch"
@echo "Makefile targets"
@echo " - test: run tests"
@echo " - coverage: run tests with coverage"
@echo
@echo "To install jsonpatch, type"
@echo " python setup.py install"
@echo
test:
python tests.py
coverage:
coverage run --source=jsonpatch tests.py
coverage report -m

View File

@ -249,7 +249,6 @@ class MakePatchTestCase(unittest.TestCase):
modules = ['jsonpatch']
coverage_modules = []
def get_suite():
@ -265,33 +264,11 @@ suite = get_suite()
for module in modules:
m = __import__(module, fromlist=[module])
coverage_modules.append(m)
suite.addTest(doctest.DocTestSuite(m))
runner = unittest.TextTestRunner(verbosity=1)
try:
import coverage
except ImportError:
coverage = None
if coverage is not None:
coverage.erase()
coverage.start()
result = runner.run(suite)
if not result.wasSuccessful():
sys.exit(1)
if coverage is not None:
coverage.stop()
coverage.report(coverage_modules)
coverage.erase()
if coverage is None:
sys.stderr.write("""
No coverage reporting done (Python module "coverage" is missing)
Please install the python-coverage package to get coverage reporting.
""")
sys.stderr.flush()