Skip to content

Commit

Permalink
Fix coverage measurement
Browse files Browse the repository at this point in the history
Now tox -e coverage correctly reports 50%.
  • Loading branch information
mgedmin committed May 15, 2020
1 parent c719033 commit f428496
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[run]
source = z3c.recipe.tag
parallel = true

[paths]
source =
src/
.tox/*/lib/python*/site-packages/
.tox/pypy*/site-packages/
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
doctests = yes
# provided to doctests by buildoutSetUp()
builtins = write, system, cat, join
4 changes: 2 additions & 2 deletions src/z3c/recipe/tag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ def build_tags(args=None):
import paver.easy
except ImportError:
HAS_PAVER = False
else:
else: # pragma: nocover
HAS_PAVER = True

if HAS_PAVER:
if HAS_PAVER: # pragma: nocover
@paver.easy.task
@paver.easy.consume_args
def tags(args):
Expand Down
6 changes: 1 addition & 5 deletions src/z3c/recipe/tag/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
def doctest_tags_recipe():
"""Test for z3c.recipe.tag
>>> write = write # noqa: F821 (undefined name)
>>> system = system # noqa: F821 (undefined name)
>>> cat = cat # noqa: F821 (undefined name)
>>> join = join # noqa: F821 (undefined name)
>>> write('buildout.cfg',
... '''
... [buildout]
Expand Down Expand Up @@ -81,7 +77,7 @@ def tearDown(test):
(re.compile("Not found: .*buildouttests/[a-zA-Z0-9.]+/\n"), ''),
])

if os.getenv('RUNNING_UNDER_TOX') or os.getenv('TRAVIS'):
if os.getenv('RUNNING_UNDER_TOX') or os.getenv('TRAVIS'): # pragma: nocover
# tox installs our test dependencies into the virtualenv,
# and zc.buildout has no site isolation, so it finds them there,
# so it doesn't add them to sys.path in the generated scripts
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ extras = test

[testenv:coverage]
basepython = python3.7
setenv =
COVERAGE_PROCESS_START={toxinidir}/.coveragerc
commands =
coverage run -m zope.testrunner --test-path=src []
coverage report --fail-under=86
coverage combine
coverage report -m --fail-under=50
deps =
coverage

Expand Down

0 comments on commit f428496

Please sign in to comment.