Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix in telegram.Message #1042

Merged
merged 2 commits into from Mar 16, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+26 −0
Diff settings

Always

Just for now

Copy path View file
@@ -868,6 +868,9 @@ def parse_caption_entities(self, types=None):

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

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

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

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

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

Copy path View file
@@ -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 not message.text_html

This comment has been minimized.

Copy link
@jh0ker

jh0ker Mar 12, 2018

Member

Perhaps change to assert message.text_html is None ?

This comment has been minimized.

Copy link
@jh0ker

jh0ker Mar 12, 2018

Member

same for the other tests of course

This comment has been minimized.

Copy link
@Eldinnie

Eldinnie Mar 12, 2018

Author Member

I could, but why?

This comment has been minimized.

Copy link
@jh0ker

jh0ker Mar 12, 2018

Member

Because it would properly test the feature. We don't want to allow empty strings, right?

This comment has been minimized.

Copy link
@Eldinnie

Eldinnie Mar 12, 2018

Author Member

I don't see why not, actually I was think of doing:

if not message_text:
  return message_text

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>. '
@@ -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 not message.text_markdown

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)')
@@ -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 not message.caption_html

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>. '
@@ -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 not message.caption_markdown

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)')
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.