We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5a200d8 commit f96fbe0Copy full SHA for f96fbe0
1 file changed
_python_utils_tests/test_aio.py
@@ -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