Skip to content

Commit

Permalink
Update test_counter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Dec 18, 2024
1 parent 405106e commit 2c99dd1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/primitives/test_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@

@pytest.mark.asyncio_cooperative
async def test_counter_lock():
counter = CounterLock()
assert counter._name == ""
assert repr(counter) == "<CounterLock value=0 waiters={}>"
coro = counter.wait_for(1)
task = asyncio.create_task(coro)
await asyncio.sleep(0)
assert repr(counter) == "<CounterLock value=0 waiters={1: 1}>"
counter.set(1)
await asyncio.sleep(0)
assert task.done() and task.result() is True
assert repr(counter) == "<CounterLock value=1 waiters={}>"


@pytest.mark.asyncio_cooperative
async def test_counter_lock_with_name():
counter = CounterLock(name="test")
assert counter._name == "test"
assert repr(counter) == "<CounterLock name=test value=0 waiters={}>"
Expand Down

0 comments on commit 2c99dd1

Please sign in to comment.