def testWeightedProb(self): c = Classifier(getwords) c.incc("Good") c.incf("hello", "Good") c.incc("Good") c.incf("world", "Good") c.incc("Good") c.incf("world", "Good") c.incc("Bad") c.incf("world", "Bad") self.assertEqual(c.weightedprob("world", "Good"), 5.0/8.0) self.assertEqual(c.weightedprob("wurst", "Good"), 0.5)