本文整理汇总了Python中twitter.Twitter.statuses_to_tweets方法的典型用法代码示例。如果您正苦于以下问题:Python Twitter.statuses_to_tweets方法的具体用法?Python Twitter.statuses_to_tweets怎么用?Python Twitter.statuses_to_tweets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.Twitter
的用法示例。
在下文中一共展示了Twitter.statuses_to_tweets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTwitter
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import statuses_to_tweets [as 别名]
class TestTwitter(unittest.TestCase):
def setUp(self):
# simulate "psh -t read" command args
args = Namespace(cargs='home', command='read', facebook=False, media='', number=10, status='', twitter=True, verbose=False)
self.t = Twitter(args)
self.t.login()
def test_login(self):
# Tests login() & indirectly, known_user_auth()
# and first_time_auth() by checking the access
# token of 'self.auth'
# read in access token from 'twitter-access-token.txt'
with open('twitter-access-token.txt', 'r') as infile:
content = infile.readlines()
access_token = content[0].rstrip()
access_token_secret = content[1].rstrip()
self.assertEqual(self.t.auth.access_token, access_token)
self.assertEqual(self.t.auth.access_token_secret, access_token_secret)
def test_get_tweepy_API(self):
# Tests get_tweepy_API & verify() indirectly
self.assertFalse(isinstance(self.t.api, tweepy.API))
self.t.get_tweepy_API()
self.assertTrue(isinstance(self.t.api, tweepy.API))
def test_statuses_to_tweets(self):
self.t.get_tweepy_API()
statuses = self.t.api.home_timeline(count=self.t.args.number)
tweets = self.t.statuses_to_tweets(statuses)
# check first element, assume the rest are the same
self.assertTrue(isinstance(tweets[0], tweet.Tweet))
tweets = self.t.statuses_to_tweets([])
self.assertFalse(tweets)