diff --git a/src/fastcs/cs_methods.py b/src/fastcs/cs_methods.py index 5bcd9a267..8f7f216b5 100644 --- a/src/fastcs/cs_methods.py +++ b/src/fastcs/cs_methods.py @@ -161,7 +161,7 @@ def _validate(self, fn: UnboundCommandCallback[Controller_T]) -> None: raise FastCSException("Command method cannot have arguments") def bind(self, controller: Controller_T) -> Command: - return Command(MethodType(self.fn, controller)) + return Command(MethodType(self.fn, controller), group=self.group) def __call__(self): raise method_not_bound_error diff --git a/tests/test_cs_methods.py b/tests/test_cs_methods.py index 7b05bb924..cda1dd96b 100644 --- a/tests/test_cs_methods.py +++ b/tests/test_cs_methods.py @@ -45,7 +45,7 @@ async def do_nothing(self): async def do_nothing_with_arg(self, arg): pass - unbound_command = UnboundCommand(TestController.do_nothing) + unbound_command = UnboundCommand(TestController.do_nothing, group="Test") with pytest.raises(NotImplementedError): await unbound_command() @@ -57,6 +57,8 @@ async def do_nothing_with_arg(self, arg): Command(TestController().do_nothing_with_arg) # type: ignore command = unbound_command.bind(TestController()) + # Test that group is passed when binding commands + assert command.group == "Test" await command()