-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support launch_ros test runner in pytest (#54)
* Support launch_ros test runner in pytest. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Test examples using pytest Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Improve pytest rostest marker documentation. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Move examples README to the root. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Remove single marker constraint for generate_test_description functions. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Please flake8 Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Install examples properly. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
- Loading branch information
Showing
8 changed files
with
235 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# launch\_testing\_ros | ||
|
||
## Examples | ||
|
||
### `talker_listener_launch_test.py` | ||
|
||
Usage: | ||
|
||
```sh | ||
launch_test test/examples/talker_listener_launch_test.py | ||
``` | ||
|
||
This test launches the talker and listener example nodes from demo\_nodes\_py and interacts | ||
with them via their ROS interfaces. Remapping rules are used so that one of the tests can sit in | ||
between the talker and the listener and change the data on the fly. | ||
|
||
#### test\_fuzzy\_data | ||
This test gives an example of what a test that fuzzes data might look like. A ROS subscriber | ||
and publisher pair encapsulated in a `DataRepublisher` object changes the string "Hello World" to | ||
"Aloha World" as it travels between the talker and the listener. | ||
|
||
#### test\_listener\_receives | ||
This test publishes unique messages on the `/chatter` topic and asserts that the same messages | ||
go to the stdout of the listener node | ||
|
||
#### test\_talker\_transmits | ||
This test subscribes to the remapped `/talker_chatter` topic and makes sure the talker node also | ||
writes the data it's transmitting to stdout |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2019 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 launch_testing.pytest.hooks import LaunchTestItem | ||
from launch_testing.pytest.hooks import LaunchTestModule | ||
|
||
from ..test_runner import LaunchTestRunner | ||
|
||
|
||
class LaunchROSTestItem(LaunchTestItem): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs, runner_cls=LaunchTestRunner) | ||
|
||
|
||
class LaunchROSTestModule(LaunchTestModule): | ||
|
||
def makeitem(self, *args, **kwargs): | ||
return LaunchROSTestItem(*args, **kwargs) | ||
|
||
|
||
def pytest_launch_collect_makemodule(path, parent, entrypoint): | ||
marks = getattr(entrypoint, 'pytestmark', []) | ||
if marks and any(m.name == 'rostest' for m in marks): | ||
return LaunchROSTestModule(path, parent) | ||
|
||
|
||
def pytest_configure(config): | ||
config.addinivalue_line( | ||
'markers', | ||
'rostest: mark a generate_test_description function as a ROS launch test entrypoint' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.