Skip to content

Commit e6236a8

Browse files
committed
Fix python3 html encoding
1 parent 3ec7a2c commit e6236a8

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

tests/test_html_converter.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from unittest import TestCase
2-
2+
import sys
33
from telegraph.utils import html_to_nodes, nodes_to_html
44

55

@@ -18,14 +18,30 @@
1818
}
1919
]
2020

21+
NODES_TEST_LIST_PY35 = [
22+
{'tag': 'p', 'children': ['Hello, world!']},
23+
{'tag': 'p', 'children': [{
24+
'tag': 'a',
25+
'attrs': {'href': 'https://telegra.ph/'},
26+
'children': ['Test link</a>']
27+
}]
28+
}
29+
]
30+
2131

2232
class TestHTMLConverter(TestCase):
2333
def test_html_to_nodes(self):
2434

25-
self.assertEqual(
26-
html_to_nodes(HTML_TEST_STR),
27-
NODES_TEST_LIST
28-
)
35+
if sys.version_info.major == 3 and sys.version_info.minor == 5:
36+
self.assertEqual(
37+
html_to_nodes(HTML_TEST_STR),
38+
NODES_TEST_LIST_PY35
39+
)
40+
else:
41+
self.assertEqual(
42+
html_to_nodes(HTML_TEST_STR),
43+
NODES_TEST_LIST
44+
)
2945

3046
def test_nodes_to_html(self):
3147
self.assertEqual(

0 commit comments

Comments
 (0)