diff --git a/bdai_ros2_wrappers/test/conftest.py b/bdai_ros2_wrappers/test/conftest.py index 9f7787e..619c3e3 100644 --- a/bdai_ros2_wrappers/test/conftest.py +++ b/bdai_ros2_wrappers/test/conftest.py @@ -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 diff --git a/bdai_ros2_wrappers/test/test_executors.py b/bdai_ros2_wrappers/test/test_executors.py index 06ce02e..d6e8ca3 100644 --- a/bdai_ros2_wrappers/test/test_executors.py +++ b/bdai_ros2_wrappers/test/test_executors.py @@ -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: diff --git a/bdai_ros2_wrappers/test/test_node.py b/bdai_ros2_wrappers/test/test_node.py index 51b643a..6b45a5e 100644 --- a/bdai_ros2_wrappers/test/test_node.py +++ b/bdai_ros2_wrappers/test/test_node.py @@ -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: