mirror of
https://github.com/kennethreitz/requests-html.git
synced 2026-06-05 06:46:14 +00:00
Merge pull request #269 from tvytlx/master
Fix: fstring formatted with bytes
This commit is contained in:
+2
-2
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user