mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-03 09:49:21 +01:00
Improve Error Messages in CommandHandler.__init__ (#2837)
This commit is contained in:
parent
ced58b790e
commit
9a8c76fc2b
2 changed files with 4 additions and 2 deletions
|
@ -97,7 +97,7 @@ class CommandHandler(Handler[Update, CCT]):
|
|||
self.command = [x.lower() for x in command]
|
||||
for comm in self.command:
|
||||
if not re.match(r'^[\da-z_]{1,32}$', comm):
|
||||
raise ValueError('Command is not a valid bot command')
|
||||
raise ValueError(f'Command `{comm}` is not a valid bot command')
|
||||
|
||||
self.filters = filters if filters is not None else filters_module.UpdateType.MESSAGES
|
||||
|
||||
|
|
|
@ -173,7 +173,9 @@ class TestCommandHandler(BaseTest):
|
|||
ids=['too long', 'invalid letter', 'invalid characters'],
|
||||
)
|
||||
def test_invalid_commands(self, cmd):
|
||||
with pytest.raises(ValueError, match='not a valid bot command'):
|
||||
with pytest.raises(
|
||||
ValueError, match=f'`{re.escape(cmd.lower())}` is not a valid bot command'
|
||||
):
|
||||
CommandHandler(cmd, self.callback_basic)
|
||||
|
||||
def test_command_list(self):
|
||||
|
|
Loading…
Reference in a new issue