Skip to content

Commit 9af7548

Browse files
committed
add tests for docs 'demo.py'
1 parent c0c232e commit 9af7548

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_doc_example.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from importlib.machinery import SourceFileLoader
2+
from pathlib import Path
3+
4+
THIS_DIR = Path(__file__).parent
5+
6+
7+
async def test_run_job_burst(redis_conn, loop, caplog):
8+
demo = SourceFileLoader('demo', str(THIS_DIR / '../docs/demo.py')).load_module()
9+
worker = demo.Worker(burst=True, loop=loop)
10+
11+
downloader = demo.Downloader(loop=loop)
12+
13+
await downloader.download_content('http://example.com')
14+
await worker.run()
15+
await downloader.close()
16+
assert 's → Downloader.download_content(http://example.com)' in caplog
17+
assert 's ← Downloader.download_content ● 1' in caplog

0 commit comments

Comments
 (0)