diff options
author | Stefan Kögl <stefan@skoegl.net> | 2013-07-08 11:36:42 +0200 |
---|---|---|
committer | Stefan Kögl <stefan@skoegl.net> | 2013-07-08 11:36:42 +0200 |
commit | 4ed55a3fb5e85ccf95ffa0f505c72af5b4bb447d (patch) | |
tree | c051c21b10d9260846d659602035d8af525fff42 | |
parent | fe29c9e6cfa8ea3833ef464438f9a9c2346b5203 (diff) | |
download | python-json-patch-4ed55a3fb5e85ccf95ffa0f505c72af5b4bb447d.tar.gz |
rework coverage calculation for coveralls.io
-rw-r--r-- | .coveragerc | 15 | ||||
-rw-r--r-- | .travis.yml | 14 | ||||
-rw-r--r-- | makefile | 17 | ||||
-rwxr-xr-x | tests.py | 23 |
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 @@ -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() |