Merge pull request #269 from tvytlx/master

Fix: fstring formatted with bytes
This commit is contained in:
Ordanis Sanchez
2019-02-22 11:03:45 -04:00
committed by GitHub
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -416,9 +416,9 @@ class HTML(BaseParser):
if isinstance(html, str):
html = html.encode(DEFAULT_ENCODING)
pq = PyQuery(html)
super(HTML, self).__init__(
# Convert unicode HTML to bytes.
element=PyQuery(html)('html') or PyQuery(f'<html>{html}</html>')('html'),
element=pq('html') or pq.wrapAll('<html></html>')('html'),
html=html,
url=url,
default_encoding=default_encoding
+9
View File
@@ -173,6 +173,15 @@ def test_absolute_links(url, link, expected):
assert html.absolute_links.pop() == expected
@pytest.mark.parser
def test_parser():
doc = """<a href='https://httpbin.org'>httpbin.org\n</a>"""
html = HTML(html=doc)
assert html.find('html')
assert html.element('a').text().strip() == 'httpbin.org'
@pytest.mark.render
def test_render():
r = get()