Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ebb6cb8

Browse files
gaborbernatmsullivan
authored andcommitted
Add support for generating code coverege reports (#6694)
1 parent dadae5f commit ebb6cb8

4 files changed

Lines changed: 58 additions & 18 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363

6464
install:
6565
- pip install -U pip setuptools
66-
- pip install -U tox==3.7.0
66+
- pip install -U tox==3.9.0
6767
- tox --notest
6868

6969
script:

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ environment:
1010

1111
install:
1212
- "git submodule update --init mypy/typeshed"
13-
- "%PYTHON%\\python.exe -m pip install -U setuptools tox==3.7.0"
13+
- "%PYTHON%\\python.exe -m pip install -U setuptools tox==3.9.0"
1414
- "%PYTHON%\\python.exe -m tox -e py37 --notest"
1515

1616
build: off

setup.cfg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,17 @@ parallel = true
5252

5353
[coverage:report]
5454
show_missing = true
55+
skip_covered = True
56+
omit = mypy/test/*
57+
exclude_lines =
58+
\#\s*pragma: no cover
59+
^\s*raise AssertionError\b
60+
^\s*raise NotImplementedError\b
61+
^\s*return NotImplemented\b
62+
^\s*raise$
63+
^if __name__ == ['"]__main__['"]:$
64+
65+
[coverage:paths]
66+
source = mypy
67+
.tox/*/lib/python*/site-packages/mypy
68+
.tox\*\Lib\site-packages\mypy

tox.ini

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
11
[tox]
2-
minversion = 3.5.1
2+
minversion = 3.8.0
33
skip_missing_interpreters = true
4-
envlist = py35,
5-
py36,
6-
py37,
7-
lint,
8-
type,
9-
docs
4+
envlist =
5+
py35,
6+
py36,
7+
py37,
8+
lint,
9+
type,
10+
docs,
1011
isolated_build = true
1112

1213
[testenv]
1314
description = run the test driver with {basepython}
15+
setenv = cov: COVERAGE_FILE={toxworkdir}/.coverage.{envname}
1416
passenv = PYTEST_XDIST_WORKER_COUNT NEWSEMANAL
1517
deps = -rtest-requirements.txt
16-
commands = pytest {posargs}
18+
commands = python -m pytest {posargs}
19+
cov: python -m pytest {posargs: --cov mypy --cov-config setup.cfg}
20+
1721

18-
[testenv:.package]
22+
[testenv:coverage]
23+
description = [run locally after tests]: combine coverage data and create report
1924
deps =
25+
coverage >= 4.5.1, < 5
26+
diff_cover >= 1.0.5, <2
27+
skip_install = True
28+
passenv =
29+
{[testenv]passenv}
30+
DIFF_AGAINST
31+
setenv = COVERAGE_FILE={toxworkdir}/.coverage
32+
commands =
33+
coverage combine --rcfile setup.cfg
34+
coverage report -m --rcfile setup.cfg
35+
coverage xml -o {toxworkdir}/coverage.xml --rcfile setup.cfg
36+
coverage html -d {toxworkdir}/htmlcov --rcfile setup.cfg
37+
diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml
38+
depends =
39+
py35,
40+
py36,
41+
py37,
42+
parallel_show_output = True
2043

2144
[testenv:lint]
2245
description = check the code style
@@ -26,19 +49,22 @@ commands = flake8 -j0 {posargs}
2649
[testenv:type]
2750
description = type check ourselves
2851
basepython = python3.7
29-
commands = python3 -m mypy --config-file mypy_self_check.ini -p mypy
52+
commands = python -m mypy --config-file mypy_self_check.ini -p mypy
3053

3154
[testenv:docs]
3255
description = invoke sphinx-build to build the HTML docs
3356
basepython = python3.7
3457
deps = -rdocs/requirements-docs.txt
35-
commands = sphinx-build -d "{toxworkdir}/docs_doctree" docs/source "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
58+
commands =
59+
sphinx-build -d "{toxworkdir}/docs_doctree" docs/source "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
60+
python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'
3661

3762
[testenv:dev]
3863
description = generate a DEV environment, that has all project libraries
3964
usedevelop = True
40-
basepython = python3.7
41-
deps = -rtest-requirements.txt
42-
-rdocs/requirements-docs.txt
43-
commands = python -m pip list --format=columns
44-
python -c 'import sys; print(sys.executable)'
65+
deps =
66+
-rtest-requirements.txt
67+
-rdocs/requirements-docs.txt
68+
commands =
69+
python -m pip list --format=columns
70+
python -c 'import sys; print(sys.executable)'

0 commit comments

Comments
 (0)