@@ -29,7 +29,7 @@ def close_connection(self, conn):
2929 pass
3030
3131
32- @pytest .mark .asyncio ()
32+ @pytest .mark .asyncio
3333async def test_valid_burst_limit (pool_cls ): # noqa: RUF029
3434 """Test that invalid burst_limit values cause errors (only at construction time)"""
3535 strategy = RandomIntStrategy ()
@@ -64,7 +64,7 @@ async def inc(self):
6464 self .n -= 1
6565
6666
67- @pytest .mark .asyncio ()
67+ @pytest .mark .asyncio
6868async def test_concurrent_get_connection (pool_cls ):
6969 """Test handling several connection requests in a short time."""
7070
@@ -87,12 +87,12 @@ async def connection_holder():
8787 await asyncio .gather (* coros )
8888
8989 assert pool .in_use == 0
90- assert (
91- pool . available . qsize () == nworkers
92- ), f" { nworkers } connections should be allocated"
90+ assert pool . available . qsize () == nworkers , (
91+ f" { nworkers } connections should be allocated"
92+ )
9393
9494
95- @pytest .mark .asyncio ()
95+ @pytest .mark .asyncio
9696async def test_currently_allocating (pool_cls ):
9797 """Test that currently_allocating is accurate."""
9898
@@ -122,22 +122,22 @@ async def worker():
122122 await counter .wait ()
123123 await asyncio .sleep (0 )
124124
125- assert (
126- pool . currently_allocating == nworkers
127- ), f" { nworkers } workers are waiting for a connection"
125+ assert pool . currently_allocating == nworkers , (
126+ f" { nworkers } workers are waiting for a connection"
127+ )
128128 ev .set () # allow the workers to get their connections
129129 await counter2 .wait ()
130130 assert pool .currently_allocating == 0
131131 assert pool .in_use == nworkers , "all workers should have their connections now"
132132 ev2 .set ()
133133 await asyncio .gather (* coros )
134134 assert pool .in_use == 0
135- assert (
136- pool . available . qsize () == nworkers
137- ), "all workers should have returned their connections"
135+ assert pool . available . qsize () == nworkers , (
136+ "all workers should have returned their connections"
137+ )
138138
139139
140- @pytest .mark .asyncio ()
140+ @pytest .mark .asyncio
141141async def test_burst (pool_cls ):
142142 """Test that bursting works when enabled and doesn't when not."""
143143
@@ -189,24 +189,24 @@ async def waiting_worker():
189189 assert pool ._waiters == 1 , "Worker should be waiting, we're at burst_limit already"
190190 burst_event .set () # Allow worker holding burst connection to finish
191191 await burst_worker # Wait for it to release the connection
192- assert (
193- not did_call_close_connection . is_set ()
194- ), "Did not churn the burst connection while there was a waiter"
192+ assert not did_call_close_connection . is_set (), (
193+ "Did not churn the burst connection while there was a waiter"
194+ )
195195 await coro # Should be able to take that burst connection we created
196- assert (
197- did_call_close_connection . is_set ()
198- ), "No more waiters, burst connection should be closed"
199- assert (
200- pool . _total == pool . max_size
201- ), "Pool should return to max size after burst capacity is not needed"
196+ assert did_call_close_connection . is_set (), (
197+ "No more waiters, burst connection should be closed"
198+ )
199+ assert pool . _total == pool . max_size , (
200+ "Pool should return to max size after burst capacity is not needed"
201+ )
202202 main_event .set () # Allow the initial workers to exit
203203 await asyncio .gather (* coros ) # Wait for initial workers to exit
204- assert (
205- pool . available . qsize () == pool . max_size
206- ), "Workers should return their connections to the pool"
204+ assert pool . available . qsize () == pool . max_size , (
205+ "Workers should return their connections to the pool"
206+ )
207207
208208
209- @pytest .mark .asyncio ()
209+ @pytest .mark .asyncio
210210async def test_stale_connections (pool_cls ):
211211 """Test that the pool doesn't hand out closed connections."""
212212
@@ -243,12 +243,12 @@ async def worker():
243243 stale_connections .add (conn )
244244
245245 async with pool .get_connection () as conn :
246- assert (
247- conn != now_stale
248- ), "Make sure connections closed by consumers are not given back out"
246+ assert conn != now_stale , (
247+ "Make sure connections closed by consumers are not given back out"
248+ )
249249
250250
251- @pytest .mark .asyncio ()
251+ @pytest .mark .asyncio
252252async def test_handling_cancellederror ():
253253 making_connection = asyncio .Event ()
254254
0 commit comments