Exemple #1
0
 def test_compose_all_failing(self):
     attr_func_1 = attribute('a', equals(3, "is not 3"))
     attr_func_2 = attribute('b', equals(2, "is not 2"))
     f = compose(attr_func_1, attr_func_2)
     result = f(Obj(a=4, b=3))
     self.assertEqual(set(['is not 2', 'is not 3']), set(result))
Exemple #2
0
 def test_compose_one_failing(self):
     attr_func_1 = attribute('a', equals(3, "is not 3"))
     attr_func_2 = attribute('b', equals(2, "is not 2"))
     f = compose(attr_func_1, attr_func_2)
     result = f(Obj(a=3, b=3))
     self.assertEqual(['is not 2'], result)
Exemple #3
0
 def test_nested_attribute(self):
     f = attribute('a.b', equals(3, "is not 3"))
     obj = Obj(a=Obj(b=3))
     result = f(obj)
     self.assertEqual([], result)
Exemple #4
0
 def test_nested_attribute_failing(self):
     f = attribute('a.b', equals(3, "is not 3"))
     obj = Obj(a=3)
     result = f(obj)
     self.assertTrue('AttributeError' in result[0])
Exemple #5
0
 def test_attribute(self):
     f = attribute('a', equals(3, "is not 3"))
     obj = Obj(a=3)
     result = f(obj)
     self.assertEqual([], result)