Example #1
0
 def test_multiple_args(self):
     """
     Succeed with multiple argument predicates.
     """
     self.assertTrue(
         predicate_any(lambda a, b: a % 2 == 0 and b % 2 == 0,
                       lambda a, b: a % 3 == 0 and b % 3 == 0)(2, 4))
Example #2
0
 def test_multiple_args(self):
     """
     Succeed with multiple argument predicates.
     """
     self.assertTrue(
         predicate_any(lambda a, b: a % 2 == 0 and b % 2 == 0,
                       lambda a, b: a % 3 == 0 and b % 3 == 0)(2, 4))
Example #3
0
 def test_multiple_kw_args(self):
     """
     Succeed with multiple keyword argument predicates.
     """
     self.assertTrue(
         predicate_any(
             lambda **k: k['a'] % 2 == 0 and k['b'] % 2 == 0,
             lambda **k: k['a'] % 3 == 0 and k['b'] % 3 == 0)(a=2, b=4))
Example #4
0
 def test_multiple_kw_args(self):
     """
     Succeed with multiple keyword argument predicates.
     """
     self.assertTrue(
         predicate_any(lambda **k: k['a'] % 2 == 0 and k['b'] % 2 == 0,
                       lambda **k: k['a'] % 3 == 0 and k['b'] % 3 == 0)(
                           a=2, b=4))
Example #5
0
 def test_combines_predicates(self):
     """
     Combine many predicates and returns another predicate
     function after applying or operator
     """
     p1 = lambda a: a % 2 == 0
     p2 = lambda a: a % 3 == 0
     p3 = lambda a: a % 5 == 0
     p = predicate_any(p1, p2, p3)
     self.assertTrue(p(2))
     self.assertTrue(p(3))
     self.assertTrue(p(5))
     self.assertTrue(p(30))
     self.assertFalse(p(7))
     self.assertFalse(p(11))
Example #6
0
 def test_combines_predicates(self):
     """
     Combine many predicates and returns another predicate
     function after applying or operator
     """
     p1 = lambda a: a % 2 == 0
     p2 = lambda a: a % 3 == 0
     p3 = lambda a: a % 5 == 0
     p = predicate_any(p1, p2, p3)
     self.assertTrue(p(2))
     self.assertTrue(p(3))
     self.assertTrue(p(5))
     self.assertTrue(p(30))
     self.assertFalse(p(7))
     self.assertFalse(p(11))
Example #7
0
 def test_combines_one(self):
     """
     Succeed with one arg also.
     """
     self.assertTrue(predicate_any(lambda a: a % 2 == 0)(4))
Example #8
0
 def test_combines_one(self):
     """
     Succeed with one arg also.
     """
     self.assertTrue(predicate_any(lambda a: a % 2 == 0)(4))