summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2013-07-08 11:36:42 +0200
committerStefan Kögl <stefan@skoegl.net>2013-07-08 11:36:42 +0200
commit4ed55a3fb5e85ccf95ffa0f505c72af5b4bb447d (patch)
treec051c21b10d9260846d659602035d8af525fff42
parentfe29c9e6cfa8ea3833ef464438f9a9c2346b5203 (diff)
downloadpython-json-patch-4ed55a3fb5e85ccf95ffa0f505c72af5b4bb447d.tar.gz
rework coverage calculation for coveralls.io
-rw-r--r--.coveragerc15
-rw-r--r--.travis.yml14
-rw-r--r--makefile17
-rwxr-xr-xtests.py23
4 files changed, 42 insertions, 27 deletions
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..40fd2df
--- /dev/null
+++ b/.coveragerc
@@ -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
diff --git a/.travis.yml b/.travis.yml
index 15b2a4a..9473cc9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..01cef8a
--- /dev/null
+++ b/makefile
@@ -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
diff --git a/tests.py b/tests.py
index 89e5274..82aa823 100755
--- a/tests.py
+++ b/tests.py
@@ -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()