10000 Bump pytest-asyncio from 0.21.2 to 0.25.0 by dependabot[bot] · Pull Request #4607 · python-telegram-bot/python-telegram-bot · GitHub
[go: up one dir, main page]

Skip to content

Bump pytest-asyncio from 0.21.2 to 0.25.0 #4607

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ markers = [
"req",
]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
log_format = "%(funcName)s - Line %(lineno)d - %(message)s"
# log_level = "DEBUG" # uncomment to see DEBUG logs

Expand Down
2 changes: 1 addition & 1 deletion requirements-unit-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build
pytest==8.3.4

# needed because pytest doesn't come with native support for coroutines as tests
pytest-asyncio==0.21.2
pytest-asyncio==0.25.0

# xdist runs tests in parallel
pytest-xdist==3.6.1
Expand Down
13 changes: 10 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from uuid import uuid4

import pytest
from pytest_asyncio import is_async_test

from telegram import (
CallbackQuery,
Expand Down Expand Up @@ -77,7 +78,12 @@ def no_rerun_after_xfail_or_flood(error, name, test: pytest.Function, plugin):

def pytest_collection_modifyitems(items: list[pytest.Item]):
"""Here we add a flaky marker to all request making tests and a (no_)req marker to the rest."""
pytest_asyncio_session_scope_marker = pytest.mark.asyncio(loop_scope="session")

for item in items: # items are the test methods
if is_async_test(item):
item.add_marker(pytest_asyncio_session_scope_marker)

parent = item.parent # Get the parent of the item (class, or module if defined outside)
if parent is None: # should never happen, but just in case
return
Expand Down Expand Up @@ -137,9 +143,10 @@ def event_loop(request):
# ever since ProactorEventLoop became the default in Win 3.8+, the app crashes after the loop
# is closed. Hence, we use SelectorEventLoop on Windows to avoid this. See
# https://github.com/python/cpython/issues/83413, https://github.com/encode/httpx/issues/914
if sys.platform.startswith("win"):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
return asyncio.get_event_loop_policy().new_event_loop()
# if sys.platform.startswith("win"):
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
# return asyncio.get_event_loop_policy().new_event_loop()
return asyncio.get_event_loop()
# loop.close() # instead of closing here, do that at the every end of the test session


Expand Down
Loading
0