v/pol
1
0
mirror of https://github.com/taroved/pol synced 2025-05-27 19:40:09 -07:00

fix inner html + test

This commit is contained in:
Your Name 2017-07-10 08:40:15 -04:00
parent 9ac0f13581
commit 576da9ca7a
2 changed files with 11 additions and 2 deletions

View File

@ -17,8 +17,6 @@ def element_to_string(element):
s = [element.text] if element.text else []
for sub_element in element:
s.append(etree.tostring(sub_element))
if sub_element.tail:
s.append(element.tail)
return ''.join(s)
def _build_link(html, doc_url, url):

11
tests.py Normal file
View File

@ -0,0 +1,11 @@
from lxml import etree
from feed import element_to_string
def test1_get_inner_html():
root = etree.fromstring('<a>1<b>2</b>3<c>4</c>5</a>')
assert element_to_string(root) == '1<b>2</b>3<c>4</c>5'
test1_get_inner_html()
print 'All tests are OK'