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

Fix pytest.warns(None) usage, deprecated in pytest 7 #6664

Merged
merged 6 commits into from
Mar 28, 2022
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: 1 addition & 0 deletions CHANGES/6663.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove a deprecated usage of pytest.warns(None)
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Artem Yushkovskiy
Arthur Darcet
Austin Scola
Ben Bader
Ben Greiner
Ben Timby
Benedikt Reinartz
Bob Haddleton
Expand Down
19 changes: 3 additions & 16 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -2444,32 +2444,19 @@ async def close(self):


async def test_async_with_session() -> None:
with pytest.warns(None) as cm:
async with aiohttp.ClientSession() as session:
pass
assert len(cm.list) == 0
async with aiohttp.ClientSession() as session:
pass

assert session.closed


async def test_session_close_awaitable() -> None:
session = aiohttp.ClientSession()
with pytest.warns(None) as cm:
await session.close()
assert len(cm.list) == 0
await session.close()

assert session.closed


async def test_close_run_until_complete_not_deprecated() -> None:
session = aiohttp.ClientSession()

with pytest.warns(None) as cm:
await session.close()

assert len(cm.list) == 0


async def test_close_resp_on_error_async_with_session(aiohttp_server: Any) -> None:
async def handler(request):
resp = web.StreamResponse(headers={"content-length": "100"})
Expand Down