Skip to content

Commit f96fbe0

Browse files
committed
Added AIO tests
1 parent 5a200d8 commit f96fbe0

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

_python_utils_tests/test_aio.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from datetime import datetime
2+
import pytest
3+
import asyncio
4+
from python_utils.aio import acount
5+
6+
7+
@pytest.mark.asyncio
8+
async def test_acount(monkeypatch: pytest.MonkeyPatch):
9+
sleeps: list[float] = []
10+
11+
async def mock_sleep(delay: float):
12+
sleeps.append(delay)
13+
14+
monkeypatch.setattr(asyncio, 'sleep', mock_sleep)
15+
16+
async for i in acount(delay=1, stop=3.5):
17+
print('i', i, datetime.now())
18+
19+
assert len(sleeps) == 4
20+
assert sum(sleeps) == 4

0 commit comments

Comments
 (0)