From dd0ec9d6c6727fcdc72b9403deaabdb2b0ea410a Mon Sep 17 00:00:00 2001 From: William Woodall Date: Fri, 15 Jun 2018 10:07:32 -0700 Subject: [PATCH] Small fixups from launch PR (#77) * fix doc typo * Check handlers being set * Remove exception note * Label linters * alpha --- launch/launch/utilities/signal_management.py | 12 +++++++++--- launch/test/test_copyright.py | 3 +++ launch_ros/package.xml | 1 + launch_ros/test/test_copyright.py | 3 +++ launch_ros/test/test_flake8.py | 3 +++ launch_ros/test/test_pep257.py | 3 +++ 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/launch/launch/utilities/signal_management.py b/launch/launch/utilities/signal_management.py index e9f6c8caa..bbd6554c0 100644 --- a/launch/launch/utilities/signal_management.py +++ b/launch/launch/utilities/signal_management.py @@ -42,6 +42,8 @@ def on_sigint(handler): It is called automatically by the constructor of `launch.LaunchService`. """ global __custom_sigint_handler + if handler is not None and not callable(handler): + raise ValueError('handler must be callable or None') __custom_sigint_handler = handler @@ -58,6 +60,8 @@ def on_sigquit(handler): It is called automatically by the constructor of `launch.LaunchService`. """ global __custom_sigquit_handler + if handler is not None and not callable(handler): + raise ValueError('handler must be callable or None') __custom_sigquit_handler = handler @@ -71,6 +75,8 @@ def on_sigterm(handler): It is called automatically by the constructor of `launch.LaunchService`. """ global __custom_sigterm_handler + if handler is not None and not callable(handler): + raise ValueError('handler must be callable or None') __custom_sigterm_handler = handler @@ -95,8 +101,8 @@ def install_signal_handlers(): If you register signal handlers before calling this function, then your signal handler will automatically be called by the signal handlers in this thread. - One exception is that if your handler raises KeyboardInterrupt and a custom - handler for SIGINT has been set with on_sigint, then that exception will be + If your handler for SIGINT raises KeyboardInterrupt, and a custom handler + for SIGINT has been set with on_sigint, then that exception will be suppressed. """ global __signal_handlers_installed_lock, __signal_handlers_installed @@ -146,5 +152,5 @@ def __on_sigterm(signum, frame): signal.signal(signal.SIGQUIT, __on_sigquit) except ValueError: _logger.error("failed to set signal handlers in 'launch.utilities.signal_management.py'") - _logger.error('this module must be imported in the main thread') + _logger.error('this function must be called in the main thread') raise diff --git a/launch/test/test_copyright.py b/launch/test/test_copyright.py index 70bc47ece..cf0fae31f 100644 --- a/launch/test/test_copyright.py +++ b/launch/test/test_copyright.py @@ -13,8 +13,11 @@ # limitations under the License. from ament_copyright.main import main +import pytest +@pytest.mark.copyright +@pytest.mark.linter def test_copyright(): rc = main(argv=['.', 'test']) assert rc == 0, 'Found errors' diff --git a/launch_ros/package.xml b/launch_ros/package.xml index 6dad4343a..3ee814f5b 100644 --- a/launch_ros/package.xml +++ b/launch_ros/package.xml @@ -18,6 +18,7 @@ ament_copyright ament_flake8 ament_pep257 + python3-pytest ament_python diff --git a/launch_ros/test/test_copyright.py b/launch_ros/test/test_copyright.py index 70bc47ece..cf0fae31f 100644 --- a/launch_ros/test/test_copyright.py +++ b/launch_ros/test/test_copyright.py @@ -13,8 +13,11 @@ # limitations under the License. from ament_copyright.main import main +import pytest +@pytest.mark.copyright +@pytest.mark.linter def test_copyright(): rc = main(argv=['.', 'test']) assert rc == 0, 'Found errors' diff --git a/launch_ros/test/test_flake8.py b/launch_ros/test/test_flake8.py index ca8aa2cd6..eff829969 100644 --- a/launch_ros/test/test_flake8.py +++ b/launch_ros/test/test_flake8.py @@ -13,8 +13,11 @@ # limitations under the License. from ament_flake8.main import main +import pytest +@pytest.mark.flake8 +@pytest.mark.linter def test_flake8(): rc = main(argv=[]) assert rc == 0, 'Found errors' diff --git a/launch_ros/test/test_pep257.py b/launch_ros/test/test_pep257.py index dd3ea28ee..3aeb4d348 100644 --- a/launch_ros/test/test_pep257.py +++ b/launch_ros/test/test_pep257.py @@ -13,8 +13,11 @@ # limitations under the License. from ament_pep257.main import main +import pytest +@pytest.mark.linter +@pytest.mark.pep257 def test_pep257(): rc = main(argv=[]) assert rc == 0, 'Found code style errors / warnings'