From a98c4a53e1cd2b623102a2d94e325a563de3ec52 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Wed, 1 Feb 2017 07:58:43 -0800 Subject: [PATCH 1/3] add flake8 test --- demo_nodes_py/package.xml | 1 + demo_nodes_py/test/test_flake8.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 demo_nodes_py/test/test_flake8.py diff --git a/demo_nodes_py/package.xml b/demo_nodes_py/package.xml index 7601a1b34..9903731dd 100644 --- a/demo_nodes_py/package.xml +++ b/demo_nodes_py/package.xml @@ -15,6 +15,7 @@ std_msgs ament_copyright + ament_flake8 ament_pep257 ament_pep8 ament_pyflakes diff --git a/demo_nodes_py/test/test_flake8.py b/demo_nodes_py/test/test_flake8.py new file mode 100644 index 000000000..aad18add8 --- /dev/null +++ b/demo_nodes_py/test/test_flake8.py @@ -0,0 +1,20 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_flake8.main import main + + +def test_pyflakes(): + rc = main(argv=[]) + assert rc == 0, 'Found errors' From c14ff662db020fe88fa82fab3db97709c56bdbad Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Wed, 1 Feb 2017 07:59:07 -0800 Subject: [PATCH 2/3] fix flake8 violations --- demo_nodes_py/services/add_two_ints_client_async_py.py | 5 +++-- demo_nodes_py/services/add_two_ints_client_py.py | 5 +++-- demo_nodes_py/services/add_two_ints_server_py.py | 6 ++++-- demo_nodes_py/topics/listener_py.py | 1 + demo_nodes_py/topics/listener_qos_py.py | 1 + demo_nodes_py/topics/talker_py.py | 1 + demo_nodes_py/topics/talker_qos_py.py | 1 + 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/demo_nodes_py/services/add_two_ints_client_async_py.py b/demo_nodes_py/services/add_two_ints_client_async_py.py index ea83a2a29..7ceb4c7ce 100644 --- a/demo_nodes_py/services/add_two_ints_client_async_py.py +++ b/demo_nodes_py/services/add_two_ints_client_async_py.py @@ -14,10 +14,10 @@ import time -import rclpy - from example_interfaces.srv import AddTwoInts +import rclpy + def main(args=None): @@ -44,5 +44,6 @@ def main(args=None): cli.call(req) rclpy.spin_once(node) + if __name__ == '__main__': main() diff --git a/demo_nodes_py/services/add_two_ints_client_py.py b/demo_nodes_py/services/add_two_ints_client_py.py index 860eededb..c28e5465c 100644 --- a/demo_nodes_py/services/add_two_ints_client_py.py +++ b/demo_nodes_py/services/add_two_ints_client_py.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import rclpy - from example_interfaces.srv import AddTwoInts +import rclpy + def main(args=None): rclpy.init(args) @@ -34,5 +34,6 @@ def main(args=None): print('Result of add_two_ints: %d' % cli.response.sum) i += 1 + if __name__ == '__main__': main() diff --git a/demo_nodes_py/services/add_two_ints_server_py.py b/demo_nodes_py/services/add_two_ints_server_py.py index 29ca22488..ab7cbbd10 100644 --- a/demo_nodes_py/services/add_two_ints_server_py.py +++ b/demo_nodes_py/services/add_two_ints_server_py.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import rclpy - from example_interfaces.srv import AddTwoInts +import rclpy + def add_two_ints_callback(request, response): response.sum = request.a + request.b @@ -39,5 +39,7 @@ def main(args=None): # (optional - otherwise it will be done automatically # when the garbage collector destroys the node object) node.destroy_service(srv) + + if __name__ == '__main__': main() diff --git a/demo_nodes_py/topics/listener_py.py b/demo_nodes_py/topics/listener_py.py index 448f005d1..a48d60fe9 100644 --- a/demo_nodes_py/topics/listener_py.py +++ b/demo_nodes_py/topics/listener_py.py @@ -38,5 +38,6 @@ def main(args=None): while rclpy.ok(): rclpy.spin_once(node) + if __name__ == '__main__': main() diff --git a/demo_nodes_py/topics/listener_qos_py.py b/demo_nodes_py/topics/listener_qos_py.py index 4b13f49f5..a03916d88 100644 --- a/demo_nodes_py/topics/listener_qos_py.py +++ b/demo_nodes_py/topics/listener_qos_py.py @@ -55,5 +55,6 @@ def main(argv=sys.argv[1:]): rclpy.spin_once(node) cycle_count += 1 + if __name__ == '__main__': main() diff --git a/demo_nodes_py/topics/talker_py.py b/demo_nodes_py/topics/talker_py.py index 4e1f20583..c1a06feeb 100644 --- a/demo_nodes_py/topics/talker_py.py +++ b/demo_nodes_py/topics/talker_py.py @@ -43,5 +43,6 @@ def main(args=None): # TODO(wjwwood): need to spin_some or spin_once with timeout sleep(1) + if __name__ == '__main__': main() diff --git a/demo_nodes_py/topics/talker_qos_py.py b/demo_nodes_py/topics/talker_qos_py.py index fad3927b0..d82e9f723 100644 --- a/demo_nodes_py/topics/talker_qos_py.py +++ b/demo_nodes_py/topics/talker_qos_py.py @@ -55,5 +55,6 @@ def main(argv=sys.argv[1:]): cycle_count += 1 sleep(1) + if __name__ == '__main__': main() From 6cbd94bbc9840413a5da6a3703acbd3187835947 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Wed, 1 Feb 2017 07:59:40 -0800 Subject: [PATCH 3/3] remove redundant pep8 and pyflakes tests --- demo_nodes_py/package.xml | 2 -- demo_nodes_py/test/test_pep8.py | 20 -------------------- demo_nodes_py/test/test_pyflakes.py | 20 -------------------- 3 files changed, 42 deletions(-) delete mode 100644 demo_nodes_py/test/test_pep8.py delete mode 100644 demo_nodes_py/test/test_pyflakes.py diff --git a/demo_nodes_py/package.xml b/demo_nodes_py/package.xml index 9903731dd..740af16d1 100644 --- a/demo_nodes_py/package.xml +++ b/demo_nodes_py/package.xml @@ -17,8 +17,6 @@ ament_copyright ament_flake8 ament_pep257 - ament_pep8 - ament_pyflakes ament_python diff --git a/demo_nodes_py/test/test_pep8.py b/demo_nodes_py/test/test_pep8.py deleted file mode 100644 index 6a42d2385..000000000 --- a/demo_nodes_py/test/test_pep8.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_pep8.main import main - - -def test_pep8(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' diff --git a/demo_nodes_py/test/test_pyflakes.py b/demo_nodes_py/test/test_pyflakes.py deleted file mode 100644 index 7ef056ac6..000000000 --- a/demo_nodes_py/test/test_pyflakes.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_pyflakes.main import main - - -def test_pyflakes(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors'