Skip to content

Commit

Permalink
add --pytest-with-coverage option (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas authored Jan 13, 2020
1 parent 2f09fbc commit adf1681
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion colcon_core/task/python/test/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def add_arguments(self, *, parser): # noqa: D102
help='Pass arguments to pytests. '
'Arguments matching other options must be prefixed by a space,\n'
'e.g. --pytest-args " --help"')
parser.add_argument(
'--pytest-with-coverage',
action='store_true',
help='Generate coverage information')

def match(self, context, env, setup_py_data): # noqa: D102
return has_test_dependency(setup_py_data, 'pytest')
Expand Down Expand Up @@ -70,7 +74,10 @@ async def step(self, context, env, setup_py_data): # noqa: D102
]
env = dict(env)

if has_test_dependency(setup_py_data, 'pytest-cov'):
if (
context.args.pytest_with_coverage or
has_test_dependency(setup_py_data, 'pytest-cov')
):
try:
from pytest_cov import __version__ as pytest_cov_version
except ImportError:
Expand Down

0 comments on commit adf1681

Please sign in to comment.