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

Unpin and upgrade pytest & co #535

Merged
merged 3 commits into from
Sep 6, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/13-hooks/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ async def login_fn(**kwargs):
insecure=config.cluster.get('insecure-skip-tls-verify'),
username=config.user.get('username'),
password=config.user.get('password'),
scheme='Bearer',
token=config.user.get('token'),
certificate_path=cert.filename() if cert else None, # can be a temporary file
private_key_path=pkey.filename() if pkey else None, # can be a temporary file
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# Everything needed to develop (test, debug) the framework.
coverage
pytest-aiohttp
pytest-asyncio==0.10.0 # until fixed: https://github.com/pytest-dev/pytest-asyncio/issues/154
pytest-asyncio
pytest-mock
pytest-cov
pytest==5.3.5 # until fixed: https://github.com/pytest-dev/pytest-asyncio/issues/154
pytest>=6.0.0
aresponses
asynctest
freezegun
Expand Down
11 changes: 10 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def assert_logs_fn(patterns, prohibited=[], strict=False):
# Helpers for asyncio checks.
#
@pytest.fixture(autouse=True)
def _no_asyncio_pending_tasks():
def _no_asyncio_pending_tasks(event_loop):
"""
Ensure there are no unattended asyncio tasks after the test.

Expand All @@ -592,9 +592,18 @@ def _no_asyncio_pending_tasks():
collection after every test, and check messages from `asyncio.Task.__del__`.
This, however, requires intercepting all event-loop creation in the code.
"""

# See `asyncio.all_tasks()` implementation for reference.
before = {t for t in list(asyncio.tasks._all_tasks) if not t.done()}

# Run the test.
yield

# Let the pytest-asyncio's async2sync wrapper to finish all callbacks. Otherwise, it raises:
# <Task pending name='Task-2' coro=<<async_generator_athrow without __name__>()>>
event_loop.run_until_complete(asyncio.sleep(0))

# Detect all leftover tasks.
after = {t for t in list(asyncio.tasks._all_tasks) if not t.done()}
remains = after - before
if remains:
Expand Down