Skip to content

Commit

Permalink
twitter entity index handling bug fix for multi code point unicode chars
Browse files Browse the repository at this point in the history
...at least i think?
  • Loading branch information
snarfed committed Feb 18, 2017
1 parent 7f28371 commit 0a97bc2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions granary/test/test_twitter.py
Expand Up @@ -1089,6 +1089,27 @@ def test_quote_tweet_to_activity_without_quoted_tweet_url_entity(self):
self.assert_equals('I agree with this https://t.co/ww6HD8KroG',
self.twitter.tweet_to_activity(quote_tweet)['object']['content'])

def test_tweet_to_object_multi_byte_unicode_chars(self):
# the first three unicode chars in this string and in the text are the '100'
# emoji, which is multi-code-point. the emacs font i use doesn't render it,
# so it looks blank.
self.assert_equals(
u'💯💯💯 (by <a href="https://twitter.com/itsmaeril">@itsmaeril</a>)',
self.twitter.tweet_to_object({
'id_str': '831552681210556416',
'text': u'💯💯💯 (by @itsmaeril) https://t.co/pWrOHzuHkP',
'entities': {
'user_mentions': [{
'screen_name': 'itsmaeril',
'indices': [8, 18]
}],
'media': [{
'indices': [20, 43],
'media_url': 'http://pbs.twimg.com/media/C4pEu77UkAAVy9l.jpg',
}]
},
})['content'])

def test_tweet_to_object_full(self):
self.assert_equals(OBJECT, self.twitter.tweet_to_object(TWEET))

Expand Down

0 comments on commit 0a97bc2

Please sign in to comment.