tox: Use pytest-cov for coverage.

This commit is contained in:
Florian Bruhin 2015-03-30 23:29:54 +02:00
parent 36421934f9
commit 96090b86fd
3 changed files with 4 additions and 65 deletions

View File

@ -1,4 +1,5 @@
[run]
branch = true
omit =
qutebrowser/__main__.py
*/__init__.py

View File

@ -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) <mail@qutebrowser.org>
#
# 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 <http://www.gnu.org/licenses/>.
"""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()

View File

@ -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 =