Handle tweets having no 'entities'

This commit is contained in:
Phil Gyford 2016-04-30 16:06:40 +01:00
parent 2faa84629b
commit b4750a851a
2 changed files with 9 additions and 1 deletions

View file

@ -324,3 +324,10 @@ class TwythonAPITestCase(unittest.TestCase):
self.assertTrue('<a href="https://twitter.com/search?q=%24AAPL" class="twython-symbol">$AAPL</a>' in tweet_text)
self.assertTrue('<a href="https://twitter.com/search?q=%24ANOTHER" class="twython-symbol">$ANOTHER</a>' not in tweet_text)
def test_html_for_tweet_no_entities(self):
"""Test HTML for tweet returns tweet text if it has no entities"""
tweet = test_tweet_object
del(tweet['entities'])
tweet_text = self.api.html_for_tweet(tweet)
self.assertEqual(tweet['text'], tweet_text)

View file

@ -544,8 +544,9 @@ class Twython(EndpointsMixin, object):
if 'retweeted_status' in tweet:
tweet = tweet['retweeted_status']
text = tweet['text']
if 'entities' in tweet:
text = tweet['text']
entities = tweet['entities']
# Mentions