From ec5eb34954070793931a6d87939bcb8643a2b4b1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 9 Nov 2024 12:36:22 +0000 Subject: [PATCH] add test to ensure warnings --- tests/test_connector.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_connector.py b/tests/test_connector.py index 1f815082e76..5eb508fad11 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -1921,6 +1921,15 @@ async def test_cleanup_closed( assert cleanup_closed_handle.cancel.called +async def test_cleanup_closed_is_noop_on_fixed_cpython() -> None: + """Ensure that enable_cleanup_closed is a noop on fixed Python versions.""" + with mock.patch("aiohttp.connector.NEEDS_CLEANUP_CLOSED", False), pytest.warns( + DeprecationWarning, match="cleanup_closed ignored" + ): + conn = aiohttp.BaseConnector(enable_cleanup_closed=True) + assert conn._cleanup_closed_disabled is True + + async def test_cleanup_closed_disabled( loop: asyncio.AbstractEventLoop, mocker: MockerFixture ) -> None: