コード例 #1
0
 def test_ratio_parameterized(self, sentence, word, expected_ratio):
     counter = WordCounter(sentence)
     self.assertAlmostEqual(expected_ratio,
                            counter.ratio_of(word),
                            delta=0.01)
コード例 #2
0
 def ratio_of_missing_word():
     counter = WordCounter("green bar green")
     return counter.ratio_of("missingWord")
コード例 #3
0
 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)