# tweets.detect_author tweet_d = { 'Secretary Hillary Clinton': [('Secretary Hillary Clinton', '"Folks marched & protested for our right to vote. They endured beatings and jail time. They sacrificed their lives for this right." --@FLOTUS\n', 1477610322, 'TweetDeck', 545, 226), ('Secretary Hillary Clinton', '"We urge voters to dump Trump and choose the clearly qualified candidate in this race: Hillary Clinton" --@DenverPost https://t.co/x62lrGm1MB\n', 1476205194, 'TweetDeck', 7165, 2225)], 'Governor Gary Johnson': [('Governor Gary Johnson', 'Join me in #Atlanta November 2. Details- https://t.co/PsOd3PZrOc #YouIn? #JohnsonWeld\n', 1478034098, 'Hootsuite', 108, 51)] } result = tweets.detect_author(tweet_d, 'Join me! #YouIn?') assert isinstance(result, str), \ '''tweets.detect_author should return a str, but returned {0}\n'''.format(type(result)) our_print(""" Hooray! The type checker passed! This does NOT necessarily mean that your functions are correct! It does mean that the functions in tweets.py: - are named correctly, - take the correct number of arguments, and - return the correct types. Be sure to thoroughly test your functions yourself before submitting.""") builtins.print = our_print
assert isinstance(result[key], list), \ '''tweets.read_tweets should contains lists as values, but the value we checked was a {0} '''.format(type(result[key])) except IndexError: assert False, \ '''The dictionary returned by read_tweets was empty and should have contained data.\n''' # tweets.most_popular tweet_d = {key: value[:] for (key, value) in TWEETS_DICTIONARY.items()} result = tweets.most_popular(tweet_d, 20180501000000, 20180801000000) assert isinstance(result, str), \ '''tweets.most_popular should return a str, but returned {0}\n'''.format(type(result)) # tweets.detect_author tweet_d = {key: value[:] for (key, value) in TWEETS_DICTIONARY.items()} result = tweets.detect_author(tweet_d, 'Join me! #UofT') assert isinstance(result, str), \ '''tweets.detect_author should return a str, but returned {0}\n'''.format(type(result)) builtins.print = our_print builtins.input = our_input builtins.open = our_open print( "================= End: checking parameter and return types =================\n" ) print("The parameter and return type checker passed.") print("This means we will be able to test your code.") print("It does NOT mean your code is necessarily correct.") print(