Skip to content

Commit 225dca8

Browse files
authored
Ensure group is passed when binding commands (#171)
1 parent 3ec51ea commit 225dca8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/fastcs/cs_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _validate(self, fn: UnboundCommandCallback[Controller_T]) -> None:
161161
raise FastCSException("Command method cannot have arguments")
162162

163163
def bind(self, controller: Controller_T) -> Command:
164-
return Command(MethodType(self.fn, controller))
164+
return Command(MethodType(self.fn, controller), group=self.group)
165165

166166
def __call__(self):
167167
raise method_not_bound_error

tests/test_cs_methods.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def do_nothing(self):
4545
async def do_nothing_with_arg(self, arg):
4646
pass
4747

48-
unbound_command = UnboundCommand(TestController.do_nothing)
48+
unbound_command = UnboundCommand(TestController.do_nothing, group="Test")
4949

5050
with pytest.raises(NotImplementedError):
5151
await unbound_command()
@@ -57,6 +57,8 @@ async def do_nothing_with_arg(self, arg):
5757
Command(TestController().do_nothing_with_arg) # type: ignore
5858

5959
command = unbound_command.bind(TestController())
60+
# Test that group is passed when binding commands
61+
assert command.group == "Test"
6062

6163
await command()
6264

0 commit comments

Comments
 (0)