mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 14:46:29 +01:00
Bump pytest
from 7.4.4 to 8.1.1 (#4218)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com> Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
This commit is contained in:
parent
ee88973fee
commit
a956dcc6a4
9 changed files with 20 additions and 22 deletions
|
@ -48,7 +48,7 @@ exclude-protected = ["_unfrozen"]
|
|||
# PYTEST:
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
addopts = "--no-success-flaky-report -rsxX"
|
||||
addopts = "--no-success-flaky-report -rX"
|
||||
filterwarnings = [
|
||||
"error",
|
||||
"ignore::DeprecationWarning",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
pre-commit # needed for pre-commit hooks in the git commit command
|
||||
|
||||
# For the test suite
|
||||
pytest==7.4.4
|
||||
pytest==8.1.1
|
||||
pytest-asyncio==0.21.1 # needed because pytest doesn't come with native support for coroutines as tests
|
||||
pytest-xdist==3.6.0 # xdist runs tests in parallel
|
||||
flaky # Used for flaky tests (flaky decorator)
|
||||
|
|
|
@ -60,7 +60,7 @@ class StringEnum(str, _enum.Enum):
|
|||
|
||||
|
||||
# Apply the __repr__ modification and __str__ fix to IntEnum
|
||||
class IntEnum(_enum.IntEnum):
|
||||
class IntEnum(_enum.IntEnum): # pylint: disable=invalid-slots
|
||||
"""Helper class for int enums where ``str(member)`` prints the value, but ``repr(member)``
|
||||
gives ``EnumName.MEMBER_NAME``.
|
||||
"""
|
||||
|
|
|
@ -29,7 +29,7 @@ those classes.
|
|||
* Most of the constants in this module are grouped into enums.
|
||||
"""
|
||||
# TODO: Remove this when https://github.com/PyCQA/pylint/issues/6887 is resolved.
|
||||
# pylint: disable=invalid-enum-extension
|
||||
# pylint: disable=invalid-enum-extension,invalid-slots
|
||||
|
||||
__all__ = [
|
||||
"BOT_API_VERSION",
|
||||
|
|
|
@ -1043,12 +1043,11 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
|
|||
loop.run_forever()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
_LOGGER.debug("Application received stop signal. Shutting down.")
|
||||
except Exception as exc:
|
||||
# In case the coroutine wasn't awaited, we don't need to bother the user with a warning
|
||||
updater_coroutine.close()
|
||||
raise exc
|
||||
finally:
|
||||
# We arrive here either by catching the exceptions above or if the loop gets stopped
|
||||
# In case the coroutine wasn't awaited, we don't need to bother the user with a warning
|
||||
updater_coroutine.close()
|
||||
|
||||
try:
|
||||
# Mypy doesn't know that we already check if updater is None
|
||||
if self.updater.running: # type: ignore[union-attr]
|
||||
|
|
|
@ -152,7 +152,6 @@ class CommandHandler(BaseHandler[Update, CCT]):
|
|||
Returns:
|
||||
:obj:`bool`: Whether the args are valid for this handler.
|
||||
"""
|
||||
# pylint: disable=too-many-boolean-expressions
|
||||
return bool(
|
||||
(self.has_args is None)
|
||||
or (self.has_args is True and args)
|
||||
|
|
|
@ -289,7 +289,7 @@ class BaseFilter:
|
|||
:attr:`telegram.Update.edited_business_message`, or :obj:`False` otherwise.
|
||||
"""
|
||||
return bool( # Only message updates should be handled.
|
||||
update.channel_post # pylint: disable=too-many-boolean-expressions
|
||||
update.channel_post
|
||||
or update.message
|
||||
or update.edited_channel_post
|
||||
or update.edited_message
|
||||
|
|
|
@ -2297,7 +2297,7 @@ class TestApplication:
|
|||
assert received_signals == [signal.SIGINT, signal.SIGTERM, signal.SIGABRT]
|
||||
|
||||
received_signals.clear()
|
||||
loop.call_later(0.6, abort_app)
|
||||
loop.call_later(0.8, abort_app)
|
||||
app.run_webhook(port=49152, webhook_url="example.com", close_loop=False)
|
||||
|
||||
if platform.system() == "Windows":
|
||||
|
|
|
@ -25,7 +25,7 @@ from tests.ext.test_commandhandler import BaseTest, is_match
|
|||
|
||||
|
||||
def combinations(prefixes, commands):
|
||||
return (prefix + command for prefix in prefixes for command in commands)
|
||||
return [prefix + command for prefix in prefixes for command in commands]
|
||||
|
||||
|
||||
class TestPrefixHandler(BaseTest):
|
||||
|
@ -40,31 +40,31 @@ class TestPrefixHandler(BaseTest):
|
|||
assert getattr(handler, attr, "err") != "err", f"got extra slot '{attr}'"
|
||||
assert len(mro_slots(handler)) == len(set(mro_slots(handler))), "duplicate slot"
|
||||
|
||||
@pytest.fixture(scope="class", params=PREFIXES)
|
||||
@pytest.fixture(params=PREFIXES)
|
||||
def prefix(self, request):
|
||||
return request.param
|
||||
|
||||
@pytest.fixture(scope="class", params=[1, 2], ids=["single prefix", "multiple prefixes"])
|
||||
@pytest.fixture(params=[1, 2], ids=["single prefix", "multiple prefixes"])
|
||||
def prefixes(self, request):
|
||||
return TestPrefixHandler.PREFIXES[: request.param]
|
||||
|
||||
@pytest.fixture(scope="class", params=COMMANDS)
|
||||
@pytest.fixture(params=COMMANDS)
|
||||
def command(self, request):
|
||||
return request.param
|
||||
|
||||
@pytest.fixture(scope="class", params=[1, 2], ids=["single command", "multiple commands"])
|
||||
@pytest.fixture(params=[1, 2], ids=["single command", "multiple commands"])
|
||||
def commands(self, request):
|
||||
return TestPrefixHandler.COMMANDS[: request.param]
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
@pytest.fixture()
|
||||
def prefix_message_text(self, prefix, command):
|
||||
return prefix + command
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
@pytest.fixture()
|
||||
def prefix_message(self, prefix_message_text):
|
||||
return make_message(prefix_message_text)
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
@pytest.fixture()
|
||||
def prefix_message_update(self, prefix_message):
|
||||
return make_message_update(prefix_message)
|
||||
|
||||
|
@ -94,12 +94,12 @@ class TestPrefixHandler(BaseTest):
|
|||
assert isinstance(handler.commands, frozenset)
|
||||
assert handler.commands == {"#cmd", "#bmd"}
|
||||
|
||||
def test_single_multi_prefixes_commands(self, prefixes, commands, prefix_message_update):
|
||||
def test_single_multi_prefixes_commands(self, prefix_message_update):
|
||||
"""Test various combinations of prefixes and commands"""
|
||||
handler = self.make_default_handler()
|
||||
result = is_match(handler, prefix_message_update)
|
||||
expected = prefix_message_update.message.text in combinations(prefixes, commands)
|
||||
return result == expected
|
||||
expected = prefix_message_update.message.text in self.COMBINATIONS
|
||||
assert result == expected
|
||||
|
||||
def test_edited(self, prefix_message):
|
||||
handler_edited = self.make_default_handler()
|
||||
|
|
Loading…
Reference in a new issue