Merge 4a99ec0157 into 5a87fc7d84
This commit is contained in:
commit
a00267b4c0
2 changed files with 20 additions and 6 deletions
|
|
@ -327,6 +327,19 @@ 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_symbols(self):
|
||||
"""Should still work if tweet object has no symbols list"""
|
||||
tweet = test_tweet_symbols_object
|
||||
# Save a copy:
|
||||
symbols = tweet['entities']['symbols']
|
||||
del tweet['entities']['symbols']
|
||||
tweet_text = self.api.html_for_tweet(tweet)
|
||||
self.assertTrue('symbols: $AAPL and' in tweet_text)
|
||||
self.assertTrue('and $ANOTHER and $A.' in tweet_text)
|
||||
# Put the symbols back:
|
||||
test_tweet_symbols_object['entities']['symbols'] = symbols
|
||||
|
||||
|
||||
def test_html_for_tweet_compatmode(self):
|
||||
tweet_text = self.api.html_for_tweet(test_tweet_compat_object)
|
||||
# link to compat web status link
|
||||
|
|
|
|||
|
|
@ -581,6 +581,7 @@ class Twython(EndpointsMixin, object):
|
|||
hashtag_html % {'hashtag': entity['text']}, display_text)
|
||||
|
||||
# Symbols
|
||||
if 'symbols' in entities:
|
||||
for entity in sorted(entities['symbols'],
|
||||
key=lambda symbol: len(symbol['text']), reverse=True):
|
||||
start, end = entity['indices'][0], entity['indices'][1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue