def setUpClass(self): """Running the HashMap and dictionary functions once to build the results needed for grading""" num_of_results = 5 self.standard_results = get_top_words_standard(source, num_of_results) self.results = top_words(source, num_of_results) self.counts = [] self.standard_counts = [] for key, value in self.standard_results: self.standard_counts.append(value) for key, value in self.results: self.counts.append(value)
def test_top_words_5(self): """Tests that the top five words returned matches the standard results""" num_of_results = 5 standard_results = get_top_words_standard(source, num_of_results) results = top_words(source, num_of_results) words = [] standard_words = [] for key, value in standard_results: standard_words.append(key) for key, value in results: words.append(key) # check that the student hash map returns the exact list as the python dict self.assertEqual(words, standard_words)