[Python-ideas] Programming recommendations (PEP 8) and boolean values

Steven D'Aprano steve at pearwood.info
Thu Aug 9 03:31:01 CEST 2012


On 09/08/12 08:04, Michael Foord wrote:

> Or when testing, I often want to check that a method *really* returns True
> or False rather than some object that happens to evaluate to True or False.

I consider that three separate unit tests:

     def testGivesTrue(self):
         for x in self.args_giving_true:
             self.assertTrue(method(x))

     def testGivesFalse(self):
         for x in self.args_giving_false:
             self.assertFalse(method(x))

     def testIsBool(self):
         for x in self.args_giving_true + self.args_giving_false:
             self.assertTrue(isinstance(method(x), bool))



-- 
Steven



More information about the Python-ideas mailing list