# tweets.extract_hashtags result = tweets.extract_hashtags( 'Statement Regarding British Referendum on E.U. Membership #DemsInPhilly') assert isinstance(result, list), \ '''tweets.extract_hashtags should return a list, but returned {0}\n'''.format(type(result)) try: assert isinstance(result[0], str), \ '''tweets.extract_hashtags should return a list of strings, but the first item of the list returned was a {0} '''.format(type(result[0])) except IndexError: assert False, \ '''The list returned by extract_hashtags was empty and should have contained data.\n''' # tweets.count_words word_d = {'statement': 1, 'regarding': 1} result = tweets.count_words('Statement Regarding British Referendum', word_d) assert isinstance(result, type(None)), \ '''tweets.count_words should return None, but returned {0}\n'''.format(type(result)) assert len(word_d) == 4, \ '''tweets.count_words should modify the argument dictionary\n''' # tweets.common_words word_d = {'statement': 10, 'regarding': 1} result = tweets.common_words(word_d, 1) assert isinstance(result, type(None)), \ '''tweets.common_words should return None, but returned {0}\n'''.format(type(result)) assert len(word_d) == 1, \ '''tweets.common_words should modify the argument dictionary''' # tweets.read_tweets try:
'#UofT Prof @ArvindUofT co-authors a report' 'report on retraining mid-career workers for #tech ' 'https://t.co/L80Ch8FUQb (via @ConversationCA)') assert isinstance(result, list), \ '''tweets.extract_hashtags should return a list, but returned {0}\n'''.format(type(result)) try: assert isinstance(result[0], str), \ '''tweets.extract_hashtags should return a list of strings, but the first item of the list returned was a {0} '''.format(type(result[0])) except IndexError: assert False, \ '''The list returned by extract_hashtags was empty and should have contained data.\n''' # tweets.count_words word_d = {'computer': 1, 'day': 1} result = tweets.count_words( "#UofT researcher by day, singer @goodkidband by night", word_d) assert isinstance(result, type(None)), \ '''tweets.count_words should return None, but returned {0}\n'''.format(type(result)) assert len(word_d) == 6, \ '''tweets.count_words should modify the argument dictionary {0}\n'''.format(word_d) # tweets.common_words word_d = {'statement': 10, 'regarding': 1} result = tweets.common_words(word_d, 1) assert isinstance(result, type(None)), \ '''tweets.common_words should return None, but returned {0}\n'''.format(type(result)) assert len(word_d) == 1, \ '''tweets.common_words should modify the argument dictionary''' # tweets.read_tweets try: