Skip to content

Commit

Permalink
Fix pytest.warns(None) usage, deprecated in pytest 7 (#6664)
Browse files Browse the repository at this point in the history
* remove pytest.warns(None)

Deprecated misuse of pytest.warns()

https://docs.pytest.org/en/latest/deprecations.html#using-pytest-warns-none

* Remove duplicate test

test_session_close_awaitable() does the exact same thing and should throw a deprecation warning already which is caught by the general filter

* PR 6664 metadata

* "Fix" spelling. Bots everywhere!

* Update 6663.bugfix

* Update 6663.bugfix

Co-authored-by: Sam Bull <aa6bs0@sambull.org>
  • Loading branch information
bnavigator and Dreamsorcerer committed Mar 28, 2022
1 parent f248705 commit 936e682
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
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

0 comments on commit 936e682

Please sign in to comment.