testing: Add code test coverage reporting.

Fixes #38.
This commit is contained in:
derAnfaenger 2017-08-21 15:03:08 +02:00 committed by Tim Abbott
parent 95021ebd56
commit a5708e4dde
6 changed files with 88 additions and 26 deletions

View file

@ -13,13 +13,17 @@ def main():
parser = argparse.ArgumentParser(description="Run tests for the zulip_botserver package.")
parser.add_argument('--coverage',
action='store_true',
help='compute test coverage')
nargs='?',
const=True,
default=False,
help='compute test coverage (--coverage combine to combine with previous reports)')
options = parser.parse_args()
if options.coverage:
import coverage
cov = coverage.Coverage(config_file="tools/.coveragerc")
if options.coverage == 'combine':
cov.load()
cov.start()
test_suites = unittest.defaultTestLoader.discover('zulip_botserver')
@ -31,8 +35,6 @@ def main():
if not result.failures and options.coverage:
cov.stop()
cov.save()
cov.combine()
cov.data_suffix = False # Disable suffix so that filename is .coverage
cov.save()
cov.html_report()