Add asyncsession.run method

This commit is contained in:
Ordanis Sanchez
2018-03-21 19:39:51 -04:00
parent 09c7b683cc
commit 69dd1cc77f
2 changed files with 29 additions and 1 deletions
+19 -1
View File
@@ -1,5 +1,5 @@
import pytest
from requests_html import HTMLSession, AsyncHTMLSession
from requests_html import HTMLSession, AsyncHTMLSession, HTMLResponse
session = HTMLSession()
@@ -30,3 +30,21 @@ async def test_async_pagination(event_loop):
for page in pages:
r = await asession.get(page)
assert await r.html.__anext__()
def test_async_run():
asession = AsyncHTMLSession()
async def test1():
return await asession.get('https://xkcd.com/1957/')
async def test2():
return await asession.get('https://reddit.com/')
async def test3():
return await asession.get('https://smile.amazon.com/')
r = asession.run(test1, test2, test3)
assert len(r) == 3
assert isinstance(r[0], HTMLResponse)