Add test for alias exact match over prefix

This commit is contained in:
Jared Miller 2026-02-08 13:48:32 -05:00
parent 68fa08d776
commit 8c83130f67
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -213,3 +213,23 @@ async def test_prefix_match_with_args(player, clean_registry):
output = "".join([call[0][0] for call in player.writer.write.call_args_list])
assert "Handler called with args: the floor" in output
@pytest.mark.asyncio
async def test_alias_exact_match_over_prefix_collision(player, clean_registry):
"""Test alias exact match wins over prefix when otherwise ambiguous."""
commands.register(
CommandDefinition(
name="look", aliases=["l"], handler=dummy_handler, mode="normal"
)
)
commands.register(
CommandDefinition(name="list", handler=dummy_handler, mode="normal")
)
await commands.dispatch(player, "l")
output = "".join([call[0][0] for call in player.writer.write.call_args_list])
# Should call handler (exact match on alias), not show ambiguous
assert "Handler called" in output
assert "or" not in output