move coverage code from tests.py to makefile

This commit is contained in:
Stefan Kögl
2013-07-07 18:48:32 +02:00
parent 8584ae9358
commit faa346f16b
2 changed files with 19 additions and 29 deletions

17
makefile Normal file
View File

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

View File

@@ -62,45 +62,18 @@ class ComparisonTests(unittest.TestCase):
self.assertNotEqual(hash(p1), hash(p3))
self.assertNotEqual(hash(p2), hash(p3))
modules = ['jsonpointer']
coverage_modules = []
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SpecificationTests))
suite.addTest(unittest.makeSuite(ComparisonTests))
modules = ['jsonpointer']
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()