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))