def test_one_zero(self): """ Test that one and zero are interpreted correctly. """ one = application._bool(1) zero = application._bool(0) self.assertIsInstance(one, bool) self.assertIsInstance(zero, bool) self.assertTrue(one) self.assertFalse(zero)
def test_bool_types(self): """ Test that the method can handle bool types. """ bool_true = application._bool(True) bool_false = application._bool(False) self.assertIsInstance(bool_true, bool) self.assertIsInstance(bool_false, bool) self.assertTrue(bool_true) self.assertFalse(bool_false)
def test_strings_success(self): """ Test that various strings for success. """ for str_truth_val in ['true', 'TRUE', ' True ', '1', '1 ']: bool_true = application._bool(str_truth_val) self.assertIsInstance(bool_true, bool) self.assertTrue(bool_true) for str_false_val in ['FALSE', 'false', ' False', '0', ' 0 ']: bool_false = application._bool(str_false_val) self.assertIsInstance(bool_false, bool) self.assertFalse(bool_false)
def test_strings_failure(self): """ All bad strings. """ for str_fail in ['123', 'Tr ue', '00', 'mario', '']: bool_false = application._bool(str_fail) self.assertIsInstance(bool_false, bool) self.assertFalse(bool_false)
def test_somethingelse(self): """ Just some object """ self.assertFalse(application._bool({0, 1, 2}))
def test_none_false(self): """ Test that None is interpreted as false. """ self.assertFalse(application._bool(None))