Skip to content

Commit 2c6c3e7

Browse files
test: add extra test case
1 parent 8dff511 commit 2c6c3e7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/trio/_tests/test_sync.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,25 @@ async def test_CapacityLimiter_zero_limit_tokens() -> None:
237237
c.total_tokens = 1
238238
assert c.statistics().tasks_waiting == 0
239239
assert c.statistics().borrowers == [6]
240-
241240
c.release_on_behalf_of(6)
241+
242+
await c.acquire_on_behalf_of(0) # total_tokens is 1
243+
244+
nursery.start_soon(c.acquire_on_behalf_of, 1)
245+
c.total_tokens = 0
246+
247+
assert c.statistics().borrowers == [0]
248+
249+
c.release_on_behalf_of(0)
250+
assert c.statistics().borrowers == []
251+
assert c.statistics().tasks_waiting == 0
252+
253+
c.total_tokens = 1
254+
await wait_all_tasks_blocked()
255+
assert c.statistics().borrowers == [1]
256+
257+
c.release_on_behalf_of(1)
258+
242259
c.total_tokens = 0
243260

244261
nursery.cancel_scope.cancel()

0 commit comments

Comments
 (0)