Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions colcon_core/task/python/test/setuppy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,40 @@


class SetuppyPythonTestingStep(PythonTestingStepExtensionPoint):
"""Use `setup.py test` to test packages."""
"""Use `unittest` to test packages."""

def __init__(self): # noqa: D107
super().__init__()
satisfies_version(
PythonTestingStepExtensionPoint.EXTENSION_POINT_VERSION, '^1.0')

def add_arguments(self, *, parser): # noqa: D102
parser.add_argument(
'--unittest-args',
nargs='*', metavar='*', type=str.lstrip,
help='Pass arguments to Python unittests. '
'Arguments matching other options must be prefixed by a space,\n'
'e.g. --unittest-args " --help"')

def match(self, context, env, setup_py_data): # noqa: D102
return True

async def step(self, context, env, setup_py_data): # noqa: D102
if context.args.retest_until_fail:
logger.warning(
"Ignored '--retest-until-fail' for package "
"'{context.pkg.name}' since 'setup.py test' does not support "
'the usage'.format_map(locals()))
"'{context.pkg.name}' since 'unittest' does not support the "
'usage'.format_map(locals()))

if context.args.retest_until_pass:
logger.warning(
"Ignored '--retest-until-pass' for package "
"'{context.pkg.name}' since 'setup.py test' does not support "
'the usage'.format_map(locals()))

cmd = [
executable,
'setup.py', 'test',
'egg_info', '--egg-base', context.args.build_base,
]
"'{context.pkg.name}' since 'unittest' does not support the "
'usage'.format_map(locals()))

cmd = [executable, '-m', 'unittest', '-v']
if context.args.unittest_args is not None:
cmd += context.args.unittest_args
rc = await check_call(context, cmd, cwd=context.args.path, env=env)
if rc and rc.returncode:
return rc.returncode