Add async iterator to HTML class

This commit is contained in:
Ordanis Sanchez
2018-03-21 15:39:56 -04:00
parent dd05a02de7
commit c12d7c6aca
2 changed files with 28 additions and 1 deletions
+17 -1
View File
@@ -1,7 +1,9 @@
from requests_html import HTMLSession
import pytest
from requests_html import HTMLSession, AsyncHTMLSession
session = HTMLSession()
def test_pagination():
pages = (
'https://xkcd.com/1957/',
@@ -14,3 +16,17 @@ def test_pagination():
r = session.get(page)
assert next(r.html)
@pytest.mark.asyncio
async def test_pagination(event_loop):
asession = AsyncHTMLSession()
pages = (
'https://xkcd.com/1957/',
'https://reddit.com/',
'https://smile.amazon.com/',
'https://theverge.com/archives'
)
for page in pages:
r = await asession.get(page)
assert await r.html.__anext__()