Skip to content

Instantly share code, notes, and snippets.

@ak64th
Last active November 25, 2016 07:13
Show Gist options
  • Save ak64th/afa1c313a2a31220206393c21bda0089 to your computer and use it in GitHub Desktop.
Save ak64th/afa1c313a2a31220206393c21bda0089 to your computer and use it in GitHub Desktop.
run tests and get coverage report
import coverage
class coverall(object):
def __enter__(self):
self.coverage = coverage.coverage()
self.coverage.erase()
self.coverage.start()
def __exit__(self, exc_type, exc_val, exc_tb):
self.coverage.stop()
self.coverage.save()
self.coverage.report()
with coverall():
# ...
# run tests
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment