nvchecker/tests/test_htmlparser.py

36 lines
844 B
Python
Raw Permalink Normal View History

# MIT licensed
# Copyright (c) 2021 ypsilik <tt2laurent.maud@gmail.com>, et al.
import pytest
2022-02-22 21:01:27 +00:00
lxml_available = True
try:
import lxml
except ImportError:
lxml_available = False
pytestmark = [
pytest.mark.asyncio,
2022-02-22 21:01:27 +00:00
pytest.mark.needs_net,
pytest.mark.skipif(not lxml_available, reason="needs lxml"),
]
async def test_xpath_ok(get_version):
ver = await get_version("aur", {
"source": "htmlparser",
"url": "https://aur.archlinux.org/",
"xpath": '//div[@id="footer"]/p[1]/a/text()',
})
assert ver.startswith('v')
assert '.' in ver
async def test_xpath_element(get_version):
ver = await get_version("aur", {
"source": "htmlparser",
"url": "https://aur.archlinux.org/",
"xpath": '//div[@id="footer"]/p[1]/a',
})
assert ver.startswith('v')
assert '.' in ver