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:
Poolitzer 2021-05-27 09:37:37 +02:00 committed by GitHub
parent 5ff3b76e18
commit 1572c61063
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -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`

View file

@ -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