def test_get_random_follower(): """ test getting a random word from the trigrams dict """ # we only need one entry for this test tri_dict = {("one", "two"): ["four", "five", "six", "seven"]} # set the seed so the answer will be consistent random.seed(1234) word = trigrams.get_random_follower(tri_dict, ("one", "two")) print("got word:", word) assert word == "seven"
def test_get_random_follower_not_there(): """ test what happens when the word pair is not there """ # we only need one entry for this test tri_dict = {("one", "two"): ["four", "five", "six", "seven"]} # here's a word pair that isn't there # make sure you get something back! word = trigrams.get_random_follower(tri_dict, ("one", "one")) print("got word:", word) assert word # this asserts that you got a non-empty string