Skip to content

Commit

Permalink
Isolate bdai_ros2_wrappers tests
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
mhidalgo-bdai committed May 17, 2024
1 parent e6f0931 commit f57f5ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
20 changes: 14 additions & 6 deletions bdai_ros2_wrappers/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@
import bdai_ros2_wrappers.scope as scope
from bdai_ros2_wrappers.scope import ROSAwareScope

import domain_coordinator

@pytest.fixture(scope="function")
def ros() -> Iterable[ROSAwareScope]:
with scope.top(global_=True, namespace="fixture") as top:

@pytest.fixture
def domain_id() -> Iterable[int]:
with domain_coordinator.domain_id() as domain_id: # to ensure node isolation
yield domain_id


@pytest.fixture
def ros(domain_id: int) -> Iterable[ROSAwareScope]:
with scope.top(global_=True, domain_id=domain_id, namespace="fixture") as top:
yield top


@pytest.fixture(scope="function")
def verbose_ros() -> Iterable[ROSAwareScope]:
@pytest.fixture
def verbose_ros(domain_id: int) -> Iterable[ROSAwareScope]:
args = ["--ros-args", "--enable-rosout-logs", "--log-level", "DEBUG"]
with scope.top(args, global_=True, namespace="fixture") as top:
with scope.top(args, global_=True, domain_id=domain_id, namespace="fixture") as top:
yield top
4 changes: 2 additions & 2 deletions bdai_ros2_wrappers/test/test_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@


@pytest.fixture
def ros_context() -> Generator[Context, None, None]:
def ros_context(domain_id: int) -> Generator[Context, None, None]:
"""A fixture yielding a managed rclpy.context.Context instance."""
context = Context()
rclpy.init(context=context)
rclpy.init(context=context, domain_id=domain_id)
try:
yield context
finally:
Expand Down
4 changes: 2 additions & 2 deletions bdai_ros2_wrappers/test/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@


@pytest.fixture
def ros_context() -> Generator[Context, None, None]:
def ros_context(domain_id: int) -> Generator[Context, None, None]:
"""A fixture yielding a managed rclpy.context.Context instance."""
context = Context()
rclpy.init(context=context)
rclpy.init(context=context, domain_id=domain_id)
try:
yield context
finally:
Expand Down

0 comments on commit f57f5ab

Please sign in to comment.