Skip to content
Merged
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
2 changes: 1 addition & 1 deletion ros2interface/ros2interface/verb/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __str__(self) -> str:
return self._raw_line_text

def is_comment(self) -> bool:
return self._msg_spec and self._msg_spec.annotations['comment']
return self._raw_line_text.lstrip().startswith('#')

def is_trailing_comment(self) -> bool:
return (
Expand Down
19 changes: 19 additions & 0 deletions ros2interface/test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

import pytest

from ros2interface.verb.show import InterfaceTextLine


# Skip cli tests on Windows while they exhibit pathological behavior
# https://github.com/ros2/build_farmer/issues/248
Expand Down Expand Up @@ -562,3 +564,20 @@ def test_show_stdin(self):
text=interface_command.output,
strict=True
)


@pytest.mark.parametrize('line_text', [
'#',
' #',
'# comment',
' # comment',
])
def test_interface_text_line_is_comment(line_text):
line = InterfaceTextLine('test_pkg', 'Test', line_text)
assert line.is_comment()


def test_interface_text_line_trailing_comment_is_not_full_line_comment():
line = InterfaceTextLine('test_pkg', 'Test', 'int32 value # trailing comment')
assert not line.is_comment()
assert line.is_trailing_comment()