X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions telegram/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,9 @@ def parse_caption_entities(self, types=None):

@staticmethod
def _parse_html(message_text, entities, urled=False):
if message_text is None:
return None

if not sys.maxunicode == 0xffff:
message_text = message_text.encode('utf-16-le')

Expand Down Expand Up @@ -962,6 +965,9 @@ def caption_html_urled(self):

@staticmethod
def _parse_markdown(message_text, entities, urled=False):
if message_text is None:
return None

if not sys.maxunicode == 0xffff:
message_text = message_text.encode('utf-16-le')

Expand Down
20 changes: 20 additions & 0 deletions tests/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ def test_text_html_simple(self):
text_html = self.test_message.text_html
assert text_html == test_html_string

def test_text_html_empty(self, message):
message.text = None
message.caption = "test"
assert message.text_html is None

def test_text_html_urled(self):
test_html_string = ('Test for &lt;<b>bold</b>, <i>ita_lic</i>, <code>code</code>, '
'<a href="http://github.com/">links</a> and <pre>pre</pre>. '
Expand All @@ -186,6 +191,11 @@ def test_text_markdown_simple(self):
text_markdown = self.test_message.text_markdown
assert text_markdown == test_md_string

def test_text_markdown_empty(self, message):
message.text = None
message.caption = "test"
assert message.text_markdown is None

def test_text_markdown_urled(self):
test_md_string = ('Test for <*bold*, _ita\_lic_, `code`, [links](http://github.com/) and '
'```pre```. [http://google.com](http://google.com)')
Expand Down Expand Up @@ -215,6 +225,11 @@ def test_caption_html_simple(self):
caption_html = self.test_message.caption_html
assert caption_html == test_html_string

def test_caption_html_empty(self, message):
message.text = "test"
message.caption = None
assert message.caption_html is None

def test_caption_html_urled(self):
test_html_string = ('Test for &lt;<b>bold</b>, <i>ita_lic</i>, <code>code</code>, '
'<a href="http://github.com/">links</a> and <pre>pre</pre>. '
Expand All @@ -228,6 +243,11 @@ def test_caption_markdown_simple(self):
caption_markdown = self.test_message.caption_markdown
assert caption_markdown == test_md_string

def test_caption_markdown_empty(self, message):
message.text = "test"
message.caption = None
assert message.caption_markdown is None

def test_caption_markdown_urled(self):
test_md_string = ('Test for <*bold*, _ita\_lic_, `code`, [links](http://github.com/) and '
'```pre```. [http://google.com](http://google.com)')
Expand Down
X Tutup