File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""Tests for connection pooling."""
22
3+ import contextlib
34from unittest .mock import AsyncMock , MagicMock , patch
45
56import pytest
@@ -104,18 +105,16 @@ async def test_cancellation_does_not_leak_connection(self) -> None:
104105 acquired = asyncio .Event ()
105106
106107 async def hold_connection ():
107- async with pool .acquire () as conn :
108+ async with pool .acquire () as _ :
108109 acquired .set ()
109110 await asyncio .sleep (10 ) # Hold forever
110111
111112 task = asyncio .create_task (hold_connection ())
112113 await acquired .wait () # Deterministic: wait until connection is acquired
113114
114115 task .cancel ()
115- try :
116+ with contextlib . suppress ( asyncio . CancelledError ) :
116117 await task
117- except asyncio .CancelledError :
118- pass
119118
120119 # Connection should have been closed, size decremented
121120 mock_conn .close .assert_called ()
@@ -188,7 +187,7 @@ async def test_close_handles_checked_out_connections(self) -> None:
188187
189188 # Acquire a connection (checks it out)
190189 ctx = pool .acquire ()
191- conn = await ctx .__aenter__ ()
190+ await ctx .__aenter__ ()
192191
193192 # Close the pool while connection is checked out
194193 await pool .close ()
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ async def raise_type_error() -> str:
7474
7575 async def test_respects_max_delay (self ) -> None :
7676 """Verify that the backoff delay is capped at max_delay."""
77- from unittest .mock import AsyncMock , patch
77+ from unittest .mock import patch
7878
7979 call_count = 0
8080 sleep_args : list [float ] = []
You can’t perform that action at this time.
0 commit comments