diff --git a/.coveragerc b/.coveragerc index 2fdf4f440..ff714c43d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,5 @@ [run] +branch = true omit = qutebrowser/__main__.py */__init__.py diff --git a/scripts/print_coverage.py b/scripts/print_coverage.py deleted file mode 100644 index 4e9443ee9..000000000 --- a/scripts/print_coverage.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: - -# Copyright 2014-2015 Florian Bruhin (The Compiler) -# -# This file is part of qutebrowser. -# -# qutebrowser is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# qutebrowser is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with qutebrowser. If not, see . - -"""Print the unittest coverage based on the HTML output. - -This can probably be deleted when switching to py.test -""" - - -import os.path -import html.parser - - -class Parser(html.parser.HTMLParser): - - """HTML parser to get the percentage from coverage's HTML output.""" - - def __init__(self): - super().__init__(convert_charrefs=True) - self._active = False - self.percentage = None - - def handle_starttag(self, tag, attrs): - if tag == 'span' and dict(attrs).get('class', None) == 'pc_cov': - self._active = True - - def handle_endtag(self, _tag): - self._active = False - - def handle_data(self, data): - if self._active: - self.percentage = data - - -def main(): - """Main entry point.""" - p = Parser() - with open(os.path.join('htmlcov', 'index.html'), encoding='utf-8') as f: - p.feed(f.read()) - print('COVERAGE: {}'.format(p.percentage)) - - -if __name__ == '__main__': - main() diff --git a/tox.ini b/tox.ini index 8abb14cd5..3743eae91 100644 --- a/tox.ini +++ b/tox.ini @@ -29,12 +29,11 @@ commands = deps = {[testenv:unittests]deps} coverage==3.7.1 + pytest-cov==1.8.1 + cov-core==1.15.0 commands = {[testenv:mkvenv]commands} - {envpython} -m coverage erase - {envpython} -m coverage run --branch --source=qutebrowser -m py.test - {envpython} -m coverage html - {envpython} scripts/print_coverage.py + {envpython} -m py.test --cov qutebrowser --cov-report term --cov-report html [testenv:misc] commands =