Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions launch/launch/actions/group_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ def parse(cls, entity: Entity, parser: Parser
) -> Tuple[Type['GroupAction'], Dict[str, Any]]:
"""Return `GroupAction` action and kwargs for constructing it."""
_, kwargs = super().parse(entity, parser)
scoped = entity.get_attr('scoped', data_type=bool, optional=True)
forwarding = entity.get_attr('forwarding', data_type=bool, optional=True)
scoped = entity.get_attr(
'scoped', data_type=bool, optional=True, can_be_str=False)
forwarding = entity.get_attr(
'forwarding', data_type=bool, optional=True, can_be_str=False)
keeps = entity.get_attr('keep', data_type=List[Entity], optional=True)
if scoped is not None:
kwargs['scoped'] = scoped
Expand Down
11 changes: 10 additions & 1 deletion launch_xml/test/launch_xml/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from launch.actions import ResetLaunchConfigurations
from launch.actions import SetLaunchConfiguration
from launch.launch_context import LaunchContext

from parser_no_extensions import load_no_extensions
import pytest


def test_group():
Expand Down Expand Up @@ -86,5 +86,14 @@ def test_group():
actions[7].visit(lc)


@pytest.mark.parametrize('attribute', ('scoped', 'forwarding'))
def test_group_rejects_invalid_boolean_attributes(attribute):
xml_file = f'<launch><group {attribute}="invalid"/></launch>'
root_entity, parser = load_no_extensions(io.StringIO(xml_file))

with pytest.raises(TypeError, match=f"Attribute '{attribute}'"):
parser.parse_description(root_entity)


if __name__ == '__main__':
test_group()
15 changes: 15 additions & 0 deletions launch_yaml/test/launch_yaml/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from launch.launch_context import LaunchContext

from parser_no_extensions import load_no_extensions
import pytest


def test_group():
Expand Down Expand Up @@ -98,5 +99,19 @@ def test_group():
actions[7].visit(lc)


@pytest.mark.parametrize('attribute', ('scoped', 'forwarding'))
def test_group_rejects_invalid_boolean_attributes(attribute):
yaml_file = f"""\
launch:
- group:
{attribute}: invalid
"""
yaml_file = textwrap.dedent(yaml_file)
root_entity, parser = load_no_extensions(io.StringIO(yaml_file))

with pytest.raises(TypeError, match=f"Attribute '{attribute}'"):
parser.parse_description(root_entity)


if __name__ == '__main__':
test_group()