diff --git a/src/blueapi/core/context.py b/src/blueapi/core/context.py index 7fd28dd14..e8082132d 100644 --- a/src/blueapi/core/context.py +++ b/src/blueapi/core/context.py @@ -113,10 +113,10 @@ def plan_2(...) -> MsgGenerator: def with_device_module(self, module: ModuleType) -> None: self.with_dodal_module(module) - def with_dodal_module(self, module: ModuleType) -> None: + def with_dodal_module(self, module: ModuleType, **kwargs) -> None: from dodal.utils import make_all_devices - for device in make_all_devices(module).values(): + for device in make_all_devices(module, **kwargs).values(): self.device(device) def plan(self, plan: PlanGenerator) -> PlanGenerator: diff --git a/tests/core/test_context.py b/tests/core/test_context.py index 36901ced8..b3a95d1ab 100644 --- a/tests/core/test_context.py +++ b/tests/core/test_context.py @@ -1,6 +1,7 @@ from __future__ import annotations from typing import Dict, List, Type, Union +from unittest.mock import patch import pytest from bluesky.protocols import Descriptor, Movable, Readable, Reading, SyncOrAsync @@ -171,6 +172,21 @@ def test_add_devices_from_module(empty_context: BlueskyContext) -> None: } == empty_context.devices.keys() +def test_extra_kwargs_in_with_dodal_module_passed_to_make_all_devices( + empty_context: BlueskyContext, +) -> None: + import tests.core.fake_device_module as device_module + + with patch("dodal.utils.make_all_devices") as mock_make_all_devices: + empty_context.with_dodal_module( + device_module, some_argument=1, another_argument="two" + ) + + mock_make_all_devices.assert_called_once_with( + device_module, some_argument=1, another_argument="two" + ) + + @pytest.mark.parametrize( "addr", ["sim", "sim_det", "sim.setpoint", ["sim"], ["sim", "setpoint"]] )