File tree Expand file tree Collapse file tree 4 files changed +49
-1
lines changed
Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ if(BUILD_TESTING)
5757 ${test_interface_files_MSG_FILES}
5858 # Cases not covered by test_interface_files
5959 msg/StringArrays.msg
60+ msg/Property.msg
6061 ADD_LINTER_TESTS
6162 SKIP_INSTALL
6263 )
@@ -80,6 +81,13 @@ if(BUILD_TESTING)
8081 ament_add_pytest_test(test_cli_extension test /test_cli_extension.py
8182 PYTHON_EXECUTABLE "${BUILDTYPE_PYTHON_EXECUTABLE} "
8283 )
84+
85+ ament_add_pytest_test(test_property_py test /test_property.py
86+ PYTHON_EXECUTABLE "${BUILDTYPE_PYTHON_EXECUTABLE} "
87+ APPEND_ENV "PYTHONPATH=${pythonpath} "
88+ APPEND_LIBRARY_DIRS "${_append_library_dirs} "
89+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /rosidl_generator_py"
90+ )
8391 endif ()
8492endif ()
8593
Original file line number Diff line number Diff line change 1+ string property
2+ string anything
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ if message.structure.members:
3636 imports .setdefault (
3737 ' import rosidl_parser.definition' , []) # used for SLOT_TYPES
3838for member in message .structure .members :
39+ if member .name != EMPTY_STRUCTURE_REQUIRED_MEMBER_NAME :
40+ imports .setdefault (
41+ ' import builtins' , []) # used for @builtins.property
3942 if (
4043 isinstance (member .type , AbstractNestedType) and
4144 isinstance (member .type .value_type , BasicType) and
@@ -405,7 +408,7 @@ noqa_string = ''
405408if member .name in dict (inspect .getmembers (builtins)).keys ():
406409 noqa_string = ' # noqa: A003'
407410}@
408- @@property@ (noqa_string)
411+ @@builtins . property @ (noqa_string)
409412 def @ (member .name )(self): @ (noqa_string)
410413 """ Message field '@(member.name)'."""
411414 return self ._ @ (member .name )
Original file line number Diff line number Diff line change 1+ # Copyright 2021 Open Source Robotics Foundation, Inc.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ from rosidl_generator_py .msg import Property
16+
17+
18+ def test_msg_property ():
19+ msg = Property ()
20+
21+ # types
22+ assert isinstance (msg .property , str )
23+ assert isinstance (msg .anything , str )
24+
25+ # default values
26+ assert '' == msg .property
27+ assert '' == msg .anything
28+
29+ # set values
30+ msg .property = 'a_value'
31+ msg .anything = 'another_value'
32+
33+ # get values
34+ assert 'a_value' == msg .property
35+ assert 'another_value' == msg .anything
You can’t perform that action at this time.
0 commit comments