def test_satisfies_any(self): p_list = [] p_list.append(predicates.less_than(8)) p_list.append(predicates.less_than(6)) p_list.append(predicates.equal_to(4)) pred = predicates.satisfies_any(p_list) assert pred(4), "4 satisfies all predicates in the list" assert pred(5), "5 satisfies only 2 predicates in the list" assert pred(7), "7 satisfies only 1 predicate in the list" assert not pred(9), "9 satisfies only no predicates in the list" self.check_str(pred)
def test_less_than(self): pred = predicates.less_than(2) assert pred(1), "one is less than two" assert pred(-1), "negative one is less than two" assert not pred(2), "two is not less than two" assert not pred(3), "three is not less than two" self.check_str(pred)
def test_Implemented(self): pred = predicates.less_than(2) try: pred.__call__(2) except NotImplementedError: assert ( False ), "invoking __call__ on an complete subclass of predicate failed" try: str(pred) except NotImplementedError: assert False, "invoking __str__ on an complete subclass of predicate failed" assert True, "implemented predicate had no problems invoking functions"