mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-16 20:29:55 +01:00
Increase Test Coverage of CallbackQueryHandler (#2520)
* Test: let's see * Test: let's see, now in the correct place * Fix: Explicitly return None in else clause also documented this behaviour clearly in the docstring * add link in doc Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de> * Fix: remove unnecessary else statement Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
This commit is contained in:
parent
5ff3b76e18
commit
1572c61063
2 changed files with 6 additions and 1 deletions
|
@ -81,7 +81,8 @@ class CallbackQueryHandler(Handler[Update]):
|
|||
DEPRECATED: Please switch to context based callbacks.
|
||||
pattern (:obj:`str` | `Pattern`, optional): Regex pattern. If not :obj:`None`, ``re.match``
|
||||
is used on :attr:`telegram.CallbackQuery.data` to determine if an update should be
|
||||
handled by this handler.
|
||||
handled by this handler. If :attr:`telegram.CallbackQuery.data` is not present, the
|
||||
:class:`telegram.CallbackQuery` update will not be handled.
|
||||
pass_groups (:obj:`bool`, optional): If the callback should be passed the result of
|
||||
``re.match(pattern, data).groups()`` as a keyword argument called ``groups``.
|
||||
Default is :obj:`False`
|
||||
|
|
|
@ -135,6 +135,10 @@ class TestCallbackQueryHandler:
|
|||
callback_query.callback_query.data = 'nothing here'
|
||||
assert not handler.check_update(callback_query)
|
||||
|
||||
callback_query.callback_query.data = False
|
||||
callback_query.callback_query.game_short_name = "this is a short game name"
|
||||
assert not handler.check_update(callback_query)
|
||||
|
||||
def test_with_passing_group_dict(self, dp, callback_query):
|
||||
handler = CallbackQueryHandler(
|
||||
self.callback_group, pattern='(?P<begin>.*)est(?P<end>.*)', pass_groups=True
|
||||
|
|
Loading…
Add table
Reference in a new issue