Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pytest from 7.4.4 to 8.1.1 #4218

Merged
merged 7 commits into from Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion telegram/_utils/enum.py
Expand Up @@ -60,7 +60,7 @@ def __str__(self) -> str:


# Apply the __repr__ modification and __str__ fix to IntEnum
class IntEnum(_enum.IntEnum):
class IntEnum(_enum.IntEnum): # pylint: disable=invalid-slots
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why pylint startet complaining about this in the last few commits. Didn't complain locally … similar for the other pylint changes …anyway, changing to make pre-commit happy

"""Helper class for int enums where ``str(member)`` prints the value, but ``repr(member)``
gives ``EnumName.MEMBER_NAME``.
"""
Expand Down
2 changes: 1 addition & 1 deletion telegram/constants.py
Expand Up @@ -29,7 +29,7 @@
* 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",
Expand Down
7 changes: 3 additions & 4 deletions telegram/ext/_application.py
Expand Up @@ -1043,12 +1043,11 @@ def __run(
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]
Expand Down
1 change: 0 additions & 1 deletion telegram/ext/_handlers/commandhandler.py
Expand Up @@ -152,7 +152,6 @@ def _check_correct_args(self, args: List[str]) -> Optional[bool]:
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)
Expand Down
2 changes: 1 addition & 1 deletion telegram/ext/filters.py
Expand Up @@ -289,7 +289,7 @@ def check_update(self, update: Update) -> Optional[Union[bool, FilterDataDict]]:
: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
Expand Down
2 changes: 1 addition & 1 deletion tests/ext/test_application.py
Expand Up @@ -2297,7 +2297,7 @@ def abort_app():
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":
Expand Down
22 changes: 11 additions & 11 deletions tests/ext/test_prefixhandler.py
Expand Up @@ -25,7 +25,7 @@


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):
Expand All @@ -40,31 +40,31 @@ def test_slot_behaviour(self):
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)

Expand Down Expand Up @@ -94,12 +94,12 @@ async def test_basic(self, app, prefix, command):
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()
Expand Down