def test_ratio_parameterized(self, sentence, word, expected_ratio): counter = WordCounter(sentence) self.assertAlmostEqual(expected_ratio, counter.ratio_of(word), delta=0.01)
def ratio_of_missing_word(): counter = WordCounter("green bar green") return counter.ratio_of("missingWord")
def ratio_of_given_word(self, sentence, word, expected_ratio): """Helper function for each set of parameters.""" counter = WordCounter(sentence) self.assertAlmostEqual(expected_ratio, counter.ratio_of(word), delta=0.01)